Search code examples
javamavennoclassdeffounderrorjava-9module-info

java Runtime error with module logic: java.lang.NoClassDefFoundError: javax/xml/ws/Service


since i migrate to jdk9 i'm getting the following error at runtime:

 java.lang.NoClassDefFoundError: javax/xml/ws/Service

I'm not getting compilation error but only runtime error. the module-info is the following:

module CXFPExGenCaller {
    requires java.xml;
    requires java.logging;
    requires java.xml.bind;
    requires java.xml.ws;
    exports ......;
}

and the pom.xml contains the following dependencies:

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.12-b141001.1542</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.2.11</version>
    <scope>test</scope>
</dependency>

even if i tried different configurations the final result is still this annoying error! Does someone has an idea of what is going on here?


Solution

  • I've understood the mistake I was doing, trying the following answer: Jdk9 module concept

    I'm using JUnit to test my class on IntelliJ IDE and I was setting only compiler option instead of setting also runtime's VM Options as per the following image: setting module options on JUnit test I'm not sure it's the best practice but this solves my current problem