2 Replies Latest reply on Jun 9, 2014 2:42 PM by gomdolyi

    Class cast exception when trying to deploy Web Service in web application (Jboss EAP 6.1.1)

    gomdolyi

      I'm trying to deploy web service in my web application and I get following exception

      ~~~

      JBWEB000309: type JBWEB000066: Exception report

      JBWEB000068: message JBWEB000261: Class my.test.HelloWorldWs is not a Servlet

      JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.

      JBWEB000070: exception

      javax.servlet.ServletException: JBWEB000261: Class my.test.HelloWorldWs is not a Servlet

              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:499)

              org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

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

      JBWEB000071: root cause

      java.lang.ClassCastException: my.test.HelloWorldWs cannot be cast to javax.servlet.Servlet

              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:499)

              org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

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

      JBWEB000072: note JBWEB000073: The full stack trace of the root cause is available in the JBoss Web/7.2.2.Final-redhat-1 logs.

      ~~~

      I configure my WEB-INF/web.xml as following

      ~~~

      <servlet>

          <servlet-name>HelloWorldService</servlet-name>

          <servlet-class>us.gov.treasury.irs.srv.test.HelloWorldWs</servlet-class> 

      </servlet>

       

       

      <servlet-mapping>

          <servlet-name>HelloWorldService</servlet-name>

          <url-pattern>/test/HelloWorldService</url-pattern>

      </servlet-mapping> 

      ~~~

      and have following configured in WEB-INF/jbossws-cxf.xml

      ~~~

      <beans

        xmlns='http://www.springframework.org/schema/beans'

        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'

        xmlns:beans='http://www.springframework.org/schema/beans'

        xmlns:jaxws='http://cxf.apache.org/jaxws'

        xsi:schemaLocation='http://www.springframework.org/schema/beans

        http://www.springframework.org/schema/beans/spring-beans.xsd

        http://cxf.apache.org/jaxws

        http://cxf.apache.org/schemas/jaxws.xsd'>

       

        <jaxws:endpoint

          id='helloWorld'

          address='http://localhost:8080/my/test/HelloWorldService'  

          implementor='my.test.HelloWorldWs'>

          <jaxws:invoker>

            <bean class='org.jboss.wsf.stack.cxf.InvokerJSE'/>

          </jaxws:invoker>

        </jaxws:endpoint>

       

      </beans>

      ~~~