cxf+spring webservice client createClient报错

J2EE 码拜 8年前 (2016-05-05) 2161次浏览
首先上代码:
private static final String WEB_SERVICE_ADDRESS = “http://172.18.137.41:8080/webservice/ws/queryuser?wsdl”;
@Override
public Boolean sendConfirm()
{
DynamicClientFactory dcf = DynamicClientFactory.newInstance();
Client client = dcf.createClient(WEB_SERVICE_ADDRESS);
try {
//Object[] os = client.invoke(“queryUserDefault”);
Object[] os = client.invoke(“queryUserById”, 1);
System.out.println(os[0].toString());
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
报错:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.cxf.staxutils.StaxUtils
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:256)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:203)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:84)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:295)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:240)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:233)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:188)
at ResManageServiceImpl.sendConfirm(ResManageServiceImpl.java:17)
说明:
1.服务器端是没有问题的
2.这是一个spring下的web项目,在项目下建个main函数直接运行上面的代码是可以获取到返回结果的,但是本人前端触发后台service调用这个函数时会报以上错误。
3.本人去cxf-core的jar包下找到了这个Class,并非不存在
4.感觉是和spring的包冲突,但是又不清楚是哪个冲突,只知道在spring-core下也有个StaxUtils类,但是在WSDLManagerImpl中是直接导入的cxf-core中的StaxUtils类
解决方案

100

http://hongtaoer.blog.51cto.com/8603047/1441477
看看能否是同样问题

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明cxf+spring webservice client createClient报错
喜欢 (0)
[1034331897@qq.com]
分享 (0)