JDK 11: java.lang.NoClassDefFoundError: javax/xml/ws/handler/soap/SOAPHandler

The javax APIs were transitioned to Jakarta, so in 2020 the proper dependency is the following:

<dependency>
    <groupId>jakarta.xml.ws</groupId>
    <artifactId>jakarta.xml.ws-api</artifactId>
    <version>2.3.3</version>
</dependency>

Here's an article summarizing what happened: Java Magazine - Transition from Java EE to Jakarta EE

And here's a very useful table with mappings between the old artifacts and the new one.


Since this is the first result on google, my issue was due to having a jar, that required javax.xml.ws classes, on the Tomcat common folder /usr/local/tomcat/lib.

The Tomcat classloader hierarchy is

      Bootstrap
          |
       System
          |
       Common
       /     \
  Webapp1   Webapp2 ...

On Java 8 the common classloader can load these classes since they are on Java JRE itself, but on Java 11, the javax.xml.ws classes are on Webapp1, and the Tomcat common classloader can not load these.

For me, the solution was to no longer deploy the jar into the Tomcat common lib folder.


Include jaxws-api in your dependencies:

<dependency>
    <groupId>javax.xml.ws</groupId>
    <artifactId>jaxws-api</artifactId>
    <version>2.3.1</version>
</dependency>

Tags:

Java