java.lang.NoClassDefFoundError : javax/xml/soap/SOAPException

We Are Going To Discuss About java.lang.NoClassDefFoundError : javax/xml/soap/SOAPException. So lets Start this Java Article.

java.lang.NoClassDefFoundError : javax/xml/soap/SOAPException

Advertisements
  1. java.lang.NoClassDefFoundError : javax/xml/soap/SOAPException

    JavaSE 8 includes package java.xml.soap.
    JavaSE 9 moved package javax.xml.soap to the module java.xml.ws.
    Modules shared with JEE (like java.xml.ws) are included in JavaSE 9, but are
    deprecated for removal from a future version of JavaSE, and
    not on the default module path.

  2. java.lang.NoClassDefFoundError : javax/xml/soap/SOAPException

    JavaSE 8 includes package java.xml.soap.
    JavaSE 9 moved package javax.xml.soap to the module java.xml.ws.
    Modules shared with JEE (like java.xml.ws) are included in JavaSE 9, but are
    deprecated for removal from a future version of JavaSE, and
    not on the default module path.

Solution 1

Advertisements

JavaSE 8 includes package java.xml.soap.
JavaSE 9 moved package javax.xml.soap to the module java.xml.ws.
Modules shared with JEE (like java.xml.ws) are included in JavaSE 9, but are
deprecated for removal from a future version of JavaSE, and
not on the default module path.

A quick workaround is to either
– run the jar with JRE 8: $MY_JRE8_HOME/bin/java -jar my.jar, or
– add a module for JRE 9: java --add-modules java.xml.ws -jar my.jar

Longer term, JavaSE projects that use modules like java.xml.ws must explicitly include the module like other libraries.

See https://stackoverflow.com/a/46359097
See JDK 9 Migration Guide: Modules Shared with JEE Not Resolved by Default

(Reproduced NoClassDefError and workarounds with zipped SOAP web service project at https://spring.io/guides/gs/producing-web-service/)

Original Author user9712582 Of This Content

Solution 2

Advertisements

Adding the following in pom file solved the issue

<!-- https://mvnrepository.com/artifact/javax.xml.soap/javax.xml.soap-api -->
<dependency>
    <groupId>javax.xml.soap</groupId>
    <artifactId>javax.xml.soap-api</artifactId>
    <version>1.4.0</version>
</dependency>

Original Author Jithin U. Ahmed Of This Content

Solution 3

Advertisements

Yes, In Java 11 java.xml.soap was completely removed.
java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException can be removed by adding the
following dependency.

<dependency>
    <groupId>jakarta.xml.soap</groupId>
    <artifactId>jakarta.xml.soap-api</artifactId>
    <version>2.0.0-RC3</version>
</dependency>

But later, you will encounter , javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found.
This can be solved by adding the following dependency.

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.5.1</version>
</dependency>

Hope, it helps!

Original Author Harisudha Of This Content

Solution 4

Advertisements

I imported this one to sort out the issue: https://mvnrepository.com/artifact/javax.xml.soap/javax.xml.soap-api/1.4.0

Original Author McCoy Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment