Java 11 - Cannot access java.sql classes with isolated classloader #5079
Replies: 6 comments 5 replies
-
Good writeup! I can see and understand your issue. I am surprised that is happening. Do your channel dependencies depend on ONLY your resource or your resource and the "Default Resource"? Using Does your use case require an isolated classloader? Does your JAR and test case work with the standard classloader? |
Beta Was this translation helpful? Give feedback.
-
Hi jonbartels
No, just depends on my "channel-lib" resource directory. In fact, my default "custom-lib" resource directory is empty.
Yes, that was my expectation, at least that's how it is working with Java 8.
Yes, my final use case depends on newer versions of already shipped JAR libraries along with Mirth Connect, so I have read somewhere that the best approach was to deploy all JAR files in a channel specific resource directory and use an isolated classloader. |
Beta Was this translation helpful? Give feedback.
-
Hi jonbartels,
Thanks for the suggestion but did not worked either. This is definitely a Java 9+ problem because I've recompiled it with Java 8 and changed back Mirth Connect to run also with Java 8 and it is working without problems. |
Beta Was this translation helpful? Give feedback.
-
This probably has more to do with hoe the isolated classloader is being created than anything else. Here is an important reference; read the final comment when this bug report was closed as "not an issue": The issue is that in Java 9 and later, the behavior of a In Java 9 and later, you get only the real core packages like The isolated ... and I think the second argument to the Unfortunately, those methods are only available in Java 9 and later, and I believe Mirth needs to be complied (or at least compilable) using Java 8, so it would need to be done using reflection just in case those methods aren't available at runtime. |
Beta Was this translation helpful? Give feedback.
-
PR created: #5470 |
Beta Was this translation helpful? Give feedback.
-
@MrWalterWhite2 - NextGen pushed a commit for a child-first classloader this week ce589cf This will resolve #5644 which is a duplicate of various other classloader cases. Tagging @dfauraz - Since you sent in a PR I thought this commit might be interesting to you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
For some reason unknown, java.sql classes are not found when using Java 11 with isolated classloader, a java.lang.NoClassDefFoundError exception is raised in mirth.log, even when we change the mcservice.vmoptions to include the recommended JAVA9+ entries.
Here is a test package I've created and compiled with Java 11:
In Mirth Connect, I've crated a custom folder where I copied my test JAR file and added it as Channel Resource to a test channel, with only a JavaScript Reader where I've put the following code:
In mirth.log this is the error that is generated:
If I deploy my test JAR file in "custom-lib" folder (without using isolated classloader) with Java 11, there is no error, so I assume access to java.sql is ok:
var obj = Packages.test.NeedsJavaSql.testSQLException();
With Java 8, both situations work without problems (with "custom-lib" and isolated classloader).
In summary:
There are already two reported bugs also pointing to problems with accessing java.sql classes in Java 11:
[BUG] Third-party JDBC drivers and java.sql.driver #4719
[BUG] DatabaseConnectionFactory.createDatabaseConnection with a custom driver fails on Java9+ #4587
Am I missing something?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions