What's wrong with the web service client example?

Viewed 32

I'm following this tutorial to make my first webservice server and client. So, on a Dynamic Web Project in Eclipse IDE, I`ve created the provider class:

public class AnimalTypeService {
    public String animalType(String animal) {
        String animalType = "";
        if ("Lion".equals(animal)) {
            animalType = "Wild";
        } else if ("Dog".equals(animal)) {
            animalType = "Domestic";
        } else {
            animalType = "I don't know!";
        }
        return animalType;
    }
}

Then created a new web service using Eclipse's wizard, deployed, and it's all right with the server and with the Web Service Explorer from Eclipse. But when I run the generated Web Service Client Application created by the wizard, I get:

SEVERE: Servlet.service() for servlet [jsp] in context with path [/MyDynamicWebProjectClient] threw exception [An exception occurred processing [sampleAnimalTypeServiceProxy/Result.jsp] at line [10]

7: <BODY>
8: <H1>Result</H1>
9: 
10: <jsp:useBean id="sampleAnimalTypeServiceProxyid" scope="session" class="com.javapapers.jee.AnimalTypeServiceProxy" />
11: <%
12: if (request.getParameter("endpoint") != null && request.getParameter("endpoint").length() > 0)
13: sampleAnimalTypeServiceProxyid.setEndpoint(request.getParameter("endpoint"));


Stacktrace:] with root cause
java.lang.NoClassDefFoundError: Could not initialize class com.javapapers.jee.AnimalTypeServiceSoapBindingStub
    at com.javapapers.jee.AnimalTypeServiceServiceLocator.getAnimalTypeService(AnimalTypeServiceServiceLocator.java:55)
    at com.javapapers.jee.AnimalTypeServiceServiceLocator.getAnimalTypeService(AnimalTypeServiceServiceLocator.java:50)
    at com.javapapers.jee.AnimalTypeServiceProxy._initAnimalTypeServiceProxy(AnimalTypeServiceProxy.java:18)
    at com.javapapers.jee.AnimalTypeServiceProxy.<init>(AnimalTypeServiceProxy.java:8)
    at org.apache.jsp.sampleAnimalTypeServiceProxy.Result_jsp._jspService(Result_jsp.java:131)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:832)

Again, if I use Eclipse's Web Service Explorer I receive the correct answers from the server. Now why the generated client can't initialize AnimalTypeServiceSoapBindingStub (root cause)? Is this a Java or Eclipse problem? Any hint?

I'm using Tomcat 9, Eclipse 2020-09 (4.17.0) and compiling the code for java 8 with eclipse's openjdk.

0 Answers
Related