java.lang.NoClassDefFoundError:javax/xml/soap/SOAPException [英] java.lang.NoClassDefFoundError : javax/xml/soap/SOAPException

查看:1766
本文介绍了java.lang.NoClassDefFoundError:javax/xml/soap/SOAPException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Spring创建了一个Web服务.在我的嵌入式tomcat服务器上运行它时,它可以正常工作.但是,当我将其打包为JAR文件并使用java -jar命令运行时,我收到此异常.

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.

我的服务发送一个简单的soap请求,服务器响应为:

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.

推荐答案

JavaSE 8包含软件包java.xml.soap.
JavaSE 9将软件包javax.xml.soap移到了模块java.xml.ws中. 与JEE共享的模块(如java.xml.ws)包含在JavaSE 9中,但
-已弃用以从将来的版本中删除JavaSE和
-不在默认设置上模块路径.

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.

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

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

从长远来看,使用像java.xml.ws这样的模块的JavaSE项目必须像其他库一样显式地包含该模块.

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

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

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

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

这篇关于java.lang.NoClassDefFoundError:javax/xml/soap/SOAPException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆