REST CXF Webservice 客户端调用服务端异常
Exception in thread "main" javax.ws.rs.client.ClientException: java.lang.NoClassDefFoundError: Could not initialize class org.apache.cxf.staxutils.StaxUtils at org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:1125) at org.apache.cxf.jaxrs.client.WebClient.doResponse(WebClient.java:1088) at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1038) at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:858) at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:832) at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:395) at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:574) at ClientWS.main(ClientWS.java:17) Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.cxf.staxutils.StaxUtils at org.apache.cxf.jaxrs.provider.JAXBElementProvider.readFrom(JAXBElementProvider.java:207) at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1288) at org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:506) at org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:1104) ... 7 more |
原因:
缺少jar包 stax2-api-3.1.1.jar,也许缺少其它jar也会有此问题
我的客户端调用服务端代码引入的jar包列表:
cxf-2.7.6.jar
geronimo-jaxws-2.2_spec-1.1.jar
javax.ws.rs-api-2.0-m10.jar
jaxb-api-2.2.6.jar
neethi-3.0.2.jar
stax2-api-3.1.1.jar
woodstox-core-asl-4.2.0.jar
wsdl4j-1.6.3.jar
xercesImpl-2.9.1.jar
xmlschema-core-2.0.jar
可能有些没有用到,但是至少有这些没有报错。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。