I am trying to understand why we are getting the following exception:
java.lang.NoClassDefFoundError: java/sql/Connection
Let me start by offering some context as to what is happening. I have a set of classes that are contained within a jar file that is added to the boot class path. Now these classes have instances that are passed to them and they call methods on those instances. In a certain cases, we are calling the isClosed method for the passed java.sql.Connection instance. This instance is not part of the boot class path so is not visible to my class. I understand that if I perform a Class.forName("java.sql.Connection");
that it will not be able to find that class. This is understood but what is strange is that if I use reflection then I am able to successfully call the isClosed method. This made me wonder if I have to update the thread context class loader. Upon checking the context class loader. It contains the platform class loader that allows me to access those classes as per java 9 migration document.
Alright, this made me wonder if there is an exception that is being thrown that is then caught and a new exception is thrown instead that does not encapsulate the original exception. I enabled jvmti exception callback and printed out the different exceptions that have been raised/caught. This information did not offer anything related to the exception. That was the only exception thrown that was related to that stack trace. It seems like this is something that the hotspot is throwing and is not generated by the java layer.
I have then tried to add the Add-Exports attribute to the manifest with the following settings java.logging/java.util.logging=ALL-UNNAMED java.sql/java.sql=ALL-UNNAMED java.xml/java.xml=ALL-UNNAMED java.xml/org.xml=ALL-UNNAMED java.xml/org.w3c=ALL-UNNAMED but that did not help.
I've even cloned the jdk 9 sources and was not able to find any clue as to how to debug this issue.
By the way, I tried to enable the debug but alas there is a bug in the jdwp agent that causes the application to crash so I can not even use the debugger to help me determine what is happening.
Any ideas, suggestions or clues would be greatly appreciated since I have run out of ideas on how to solve this issue.
Note this issue is only apparent when using java 9. Our jar file is generated using java 5 since we support java 5 or greater.