服务布署完后客户端测试,提示Caused by: java.lang.ClassNotFoundException: org.apache.axis.soap.SOAPFactoryImpl

5 views
Skip to first unread message

球球

unread,
Dec 23, 2008, 4:59:55 AM12/23/08
to cxf-zh
服务端正常发布,正常启动,写客户端测试,此服务包含soap包头。网上搜索,都写的不明不白,有一些步骤试过也不顶用,下载axis包后,也没找到类
似提示中要求的类 org.apache.axis.soap.SOAPFactoryImpl。
分三步贴出详细信息。
一。报错信息
javax.xml.ws.WebServiceException: Cannot create SAAJ factory instance.
at org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl.getSOAPFactory
(SOAPBindingImpl.java:118)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:
193)
at $Proxy27.heartBeat(Unknown Source)
at urm.testcase.TestMonitorService.testHeartBeat
(TestMonitorService.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run
(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run
(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run
(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
(RemoteTestRunner.java:196)
Caused by: javax.xml.soap.SOAPException: Failed to create
SOAPConnectionFactory: org.apache.axis.soap.SOAPFactoryImpl
at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:46)
at org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl.getSOAPFactory
(SOAPBindingImpl.java:113)
... 22 more
Caused by: java.lang.ClassNotFoundException:
org.apache.axis.soap.SOAPFactoryImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:41)
... 23 more
二。服务端代码
@WebService(targetNamespace="http://my.com/my/service/MonitorService/
0.1")
@SOAPBinding(use=SOAPBinding.Use.LITERAL,
style=SOAPBinding.Style.DOCUMENT)
public interface MonitorInterface {
public byte[] getByKpis(
@WebParam(name = "sys_id")String sys_id,
@WebParam(name = "kpi_ids")String[] kpi_ids,
@WebParam(name="RequestHead", targetNamespace="http://my.com/my/
service/MonitorService/MessageHead/0.1", header=true) RequestHeadType
requestHead);
public byte[] getByDate(
@WebParam(name = "sys_id")String sys_id,
@WebParam(name = "kpi_ids")String[] kpi_ids,
@WebParam(name = "strTime")String strTime,
@WebParam(name = "endTime")String endTime,
@WebParam(name="RequestHead", targetNamespace="http://my.com/my/
service/MonitorService/MessageHead/0.1", header=true) RequestHeadType
requestHead);
public boolean heartBeat(
@WebParam(name="RequestHead", targetNamespace="http://my.com/my/
service/MonitorService/MessageHead/0.1", header=true) RequestHeadType
requestHead);
}
3.客户端代码
public class TestMonitorService extends TestCase {

protected final Log log = LogFactory.getLog(getClass());

private URL url=null;
private MonitorInterface monitorService=null;
RequestHeadType requestHead =new RequestHeadType();
protected void setUp() throws Exception {
url = new URL("http://localhost:8080/test/services/monitorService?
wsdl");
URMMonitorService monitorServiceService = new URMMonitorService
(url);
monitorService = monitorServiceService.getMonitorServicePort();
requestHead.setRequestID("001");
requestHead.setSourceSysID("zk-001");
requestHead.setTargetSysID("urm-001");
}
public final void testHeartBeat() throws Exception{
System.out.println("OK");
try{
HeartBeat heartBeat_parameters = null;
RequestHeadType heartBeat_requestHead = null;
HeartBeatResponse heartBeat__return=monitorService.heartBeat
(heartBeat_parameters, heartBeat_requestHead);
boolean ifActive=heartBeat__return.isReturn();
}catch(Exception ex){
ex.printStackTrace();
}
} }

Freeman Fang

unread,
Dec 23, 2008, 7:18:18 AM12/23/08
to cxf...@googlegroups.com
你应该用sun's saaj impl, 而不是axis saaj impl.

Freeman

Freeman Fang

unread,
Dec 23, 2008, 8:50:13 PM12/23/08
to cxf...@googlegroups.com
你的环境中也许有axis的saaj-api, 这里指定了axis的saaj-imp做为spi, 但是cxf
需要用到的是sun的saaj-api 和sun的saaj-impl, 你需要替换一下

Freeman

球球

unread,
Dec 24, 2008, 3:33:15 AM12/24/08
to cxf-zh
按你说的方法试过了,在下面地址下载的JAR包,是sun的。可是问题依旧。
不过在测试过程中,发现这样一个怪事,如果直接用实现体做服务类,然后根据生成的wsdl生成代理类,再测试没问题,但是如果服务类继承了接口,采用了
endpointInterface这种属性,再根据wsdl生成代理类,测试的时候就和我贴子发的错误一模一样了,真奇怪。
1.不用接口的服务类示例:(最终测试正常)
@WebService(serviceName="MonitorService", targetNamespace="http://
my.com/test/service/MonitorService/0.1")
@SOAPBinding(use=SOAPBinding.Use.LITERAL,
style=SOAPBinding.Style.DOCUMENT)
public class MonitorService implements MonitorInterface{

protected final Log log = LogFactory.getLog(getClass());
public byte[] getByKpis(String sys_id, String[]
kpi_ids,RequestHeadType soapHeader) {
log.info("OK");
}

2.用接口的服务类示例(测试报错)
服务类:
@WebService
(endpointInterface="test.webservice.service.MonitorInterface" ,serviceName="MonitorService",
targetNamespace="http://my.com/test/service/MonitorService/0.1")
@SOAPBinding(use=SOAPBinding.Use.LITERAL,
style=SOAPBinding.Style.DOCUMENT)
public class MonitorService implements MonitorInterface{


protected final Log log = LogFactory.getLog(getClass());

public byte[] getByKpis(String sys_id, String[]
kpi_ids,RequestHeadType soapHeader) {log.info("实现过程");}
接口类:
@WebService(targetNamespace="http://my.com/test/service/MonitorService/


0.1")
@SOAPBinding(use=SOAPBinding.Use.LITERAL,
style=SOAPBinding.Style.DOCUMENT)
public interface MonitorInterface {
public byte[] getByKpis(
@WebParam(name = "sys_id")String sys_id,
@WebParam(name = "kpi_ids")String[] kpi_ids,

@WebParam(name="RequestHead", targetNamespace="http://my.com/test/

姜宁

unread,
Dec 25, 2008, 8:05:17 AM12/25/08
to cxf-zh
你能比较一下两种方式生成的WSDL有什么不同吗?
Reply all
Reply to author
Forward
0 new messages