I've created an Axis2 web service and a client for it. I want to use this client in my servlet. I've got types in my ServiceStub (classes with fields and getters/setters for these fields). If I want to use the client which uses the stub and these types, I get errors. I tried not to use the types but I got the same error for the stub: java.lang.NoClassDefFoundError: services/ManagerServiceStub.
Here is a part of my code:
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;
}
}
This method is called from the servlet. If it is called from the simple Java Application it works just fine. The stack trace:
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)
The one thing in my mind is that I use the servlet and web service on the same tomcat server. On the other hand they both work if the servlet doesn't try to call the web service.
It clearly says at runtime your servlet couldn't find the stubs..have you kept the stub classes in the classpath where the servlet can access it? Make sure the stubs are available in the classpath.