无法在servlet中使用Axis2 Web服务存根

时间:2013-04-11 12:25:18

标签: java servlets axis2

我为它创建了一个Axis2 Web服务和客户端。我想在我的servlet中使用这个客户端。我的ServiceStub中有类型(带有字段的类和这些字段的getter / setter)。如果我想使用使用存根和这些类型的客户端,我会收到错误。我尽量不使用这些类型但是我对存根有同样的错误:java.lang.NoClassDefFoundError: services/ManagerServiceStub.这是我的代码的一部分:

public static Protocol[] someMethod(ServiceMessage srvMsg) {
        try {
            ProtocolMessage prMsg = ManagerServiceClient.getProtocols("user","pw");
            if (prMsg.getCode() == 1)
                return prMsg.getProtocolArray();
            else
                return null;
        } catch (Exception e) {
            System.err.println("Failed getting protocolos");
            e.printStackTrace(System.err);
            return null;
        }
    }

从servlet调用此方法。如果从简单的Java应用程序调用它就可以正常工作。 堆栈跟踪:

SEVERE: Servlet.service() for servlet [servlets.Node] in context with path [/nodeCreation] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoClassDefFoundError: services/ManagerServiceStub
    at client.ManagerServiceClient.getStub(ManagerServiceClient.java:28)
    at client.ManagerServiceClient.getProtocols(ManagerServiceClient.java:116)
    at jsp.Protocols.someMethod(Protocols.java:11)
    at servlets.Node.doGet(Node.java:35)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

我想到的一件事是我在同一个tomcat服务器上使用servlet和web服务。另一方面,如果servlet没有尝试调用Web服务,它们都可以工作。

1 个答案:

答案 0 :(得分:0)

它清楚地说在运行时你的servlet找不到存根。你是否将存根类保存在servlet可以访问它的类路径中? 确保存根在类路径中可用。