首页 > 技术文章 > nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPElement

z-jx 2019-08-12 09:53 原文

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

 

译文:

JavaSE 8包含包java.xml.soap
JavaSE 9将包移动javax.xml.soap到模块java.xml.ws
与JEE(如共享的模块java.xml.ws)包括在JavaSE的9,但
弃用用于去除从JavaSE中的未来版本,以及
不是默认模块路径上

一个快速的解决方法是
- 使用JRE 8运行jar:$MY_JRE8_HOME/bin/java -jar my.jar
- 为JRE 9添加模块:java --add-modules java.xml.ws -jar my.jar

从长远来看,使用类似模块的JavaSE项目java.xml.ws必须像其他库一样明确地包含模块。

请参阅https://stackoverflow.com/a/46359097
请参阅JDK 9迁移指南:与JEE共享的模块默认情况下未解析

(在https://spring.io/guides/gs/producing-web-service/上重现了NoClassDefError和压缩SOAP Web服务项目的变通方法

 

推荐阅读