5

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?

4

1 回答 1

8

Java EE 模块随 JDK 一起提供,但默认情况下不解析java.xml.bind就是其中之一。在这种情况下,它们需要明确包含在--add-modules.

在您的情况下,使用--add-modules java.xml.bind.

于 2017-03-20T20:18:31.253 回答