4 Replies Latest reply on Jan 31, 2013 5:55 AM by bmajsak

    showcase jaxws error cannot be cast to javax.servlet.Servlet

    bodtx

      Hello all, I was playing with the show case exemples.

      i have a problem to run the jaxws test with glassfish embedded (as well for tomcat embedded)

       

      when running his command:

      arquillian-showcase\jaxws>mvn -Parq-tomcat6-embedded clean package

       

      the test EchoWebServiceEndpointTestCase fails with

      WARNING: StandardWrapperValve[EchoService]: PWC1382: Allocate exception for servlet EchoService

      java.lang.ClassCastException: com.acme.jaxws.EchoWebServiceEndpointBean cannot be cast to javax.servlet.Servlet

              at com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:729)

              at com.sun.enterprise.web.WebModule.createServletInstance(WebModule.java:1959)

              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1264)

              at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1071)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:189)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

              at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

              at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)

              at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

              at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)

              at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)

              at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)

              at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)

              at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)

              at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)

              at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

              at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

              at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

              at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

              at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

              at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

              at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

              at java.lang.Thread.run(Thread.java:722)

       

      Note that to run it under glassfish I have to set the webxml version to in the test:

      WebAppDescriptor webXml = Descriptors.create(WebAppDescriptor.class).metadataComplete(true).version("3.0");

       

      Any idea about what's wrong?

       

      thx and nice job for thuis showcase.

        • 1. Re: showcase jaxws error cannot be cast to javax.servlet.Servlet
          bmajsak

          Most likely you have 2 different versions of servlet-api jar on the classpath. Beauty of embedded containers

          • 2. Re: showcase jaxws error cannot be cast to javax.servlet.Servlet
            bodtx

            Well it seems logic indeed but when looking in the maven dependencies, everything about servlet is in scope provided. So only the glassfish servlet api should be there. (no extra jar added when Iook at the package with a mvn package)

            • 3. Re: showcase jaxws error cannot be cast to javax.servlet.Servlet
              bodtx

              ok found a solution for glassfish, it seems there is no reason to declare again the webservice as a servlet in the webxml as it is annoted @webservice, so comment the servlet declaration did the trick:

               

              public static WebArchive createDeployment() {

                      WebAppDescriptor webXml = Descriptors.create(WebAppDescriptor.class).metadataComplete(true).version("3.0");

               

                      return ShrinkWrap.create(WebArchive.class, "jaxws-endpoint-test.war").addPackage(EchoWebServiceEndpointBean.class.getPackage())

                      // .setWebXML(

                      // new StringAsset(webXml.createServlet().servletName(ECHO_SERVICE_NAME).servletClass(EchoWebServiceEndpointBean.class.getName()).up()

                      // .createServletMapping().servletName(ECHO_SERVICE_NAME).urlPattern("/" + ECHO_SERVICE_NAME).up().exportAsString()))

                      ;

                  }

               

              No looking to do the same for tomcat but it is not happy with an empty web.xml

              1 of 1 people found this helpful
              • 4. Re: showcase jaxws error cannot be cast to javax.servlet.Servlet
                bmajsak

                Pull request would be more than welcome