日期:2014-05-20  浏览次数:20806 次

Axis2客户端调用web service出现ClassNotFoundException异常
在eclipse下建立了一个java projet,然后定义了一个wsdl文件和CodeGenerator.java实现简单的合并字符串功能:

input parameters : String a, String b, String c
output parameters : String d
operation: d = a + b + c

环境:Axis2 1.6.1,xercesImpl 2.9.1, Tomcat 5, java 1.6

生成服务器端代码,客户端调用运行正常。
在次基础上,服务器端导入了其他包和代码,输入输出参数均未改变,客户端无变化,重新修改了operation,打包部署后结果客户端调用时出现以下错误:

Exception in thread "main" org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.local.LocalTransportSender
at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:708)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:122)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:857)
at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:151)
at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:144)
at com.sesin.teditorservice.TEditorServiceStub.<init>(TEditorServiceStub.java:91)
at com.sesin.teditorservice.TEditorServiceStub.<init>(TEditorServiceStub.java:77)
at com.sesin.teditorservice.TEditorServiceStub.<init>(TEditorServiceStub.java:123)
at com.sesin.teditorservice.TEditorService.main(TEditorService.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.transport.local.LocalTransportSender
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.axis2.util.Loader.loadClass(Loader.java:261)
at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:683)
... 11 more

保留导入的包,operation恢复到最早合并字符串操作的情况下,客户端调用依然出现上述异常。尝试异常定位也未找到原因。

请教各位是否遇到过类似的情况,感谢分享您的解决之道或者提供相关的线索。

------解决方案--------------------
关键错误是:java.lang.ClassNotFoundException: org.apache.axis2.transport.local.LocalTransportSender

检查下你是不是在设置打包的JAR包引用时,漏了某个JAR包?

可以在Eclipse里面先找找看LocalTransportSender所在的JAR包名称。