问题
I have a server kit that I'm trying to test on the java9 JDK (found here, I'm using the 64-bit Linux version), however I'm encountering the following error shortly after startup:
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:533)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:186)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:476)
The server kit starts without issue when using java8. Somehow I need to tell the runtime system to include the javax.xml.bind
module, however I'm new to java9 and don't know how to do this short of recompiling the entire server kit into a module and adding a dependency on the javax.xml.bind
module. Is there a way to resolve this error that doesn't require me to recompile the server kit into a module?
回答1:
Java EE modules are shipped with the JDK but not resolved by default and java.xml.bind is one of them. In such cases they need to be included explicitly with --add-modules
.
In your case, launch with --add-modules java.xml.bind
.
来源:https://stackoverflow.com/questions/42907605/how-do-i-include-a-java-9-module-at-runtime