Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

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

I have created a Web Service using Spring. It works fine when running it on my embedded tomcat server. However when I package it as a JAR file and run it with java -jar command, I am receiving this exception.

My service sends a simple soap request and the server response is:

 "exception": "java.lang.NoClassDefFoundError",
    "message": "javax/xml/soap/SOAPException",

That's the response I get in Postman.

Any ideas where I can look for the problem.

question from:https://stackoverflow.com/questions/65840156/how-to-make-caused-by-java-lang-noclassdeffounderror-javax-xml-ws-soap-soapfau

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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/)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...