0 Replies Latest reply on Jun 29, 2010 5:19 AM by Paweł Stokowiec

    POJO web service cannot be cast to javax.servlet.Servlet

    Paweł Stokowiec Newbie

      Hello,

       

      In JBoss 4.2.3GA, JBossWS 3.1.1-native when you name POJO web service endpoint with suffix "Servlet" then it cannot be call due to exception:

      {quote}java.lang.ClassCastException: package.name.MyWsServlet cannot be cast to javax.servlet.Servlet{quote}

       

      Pojo servlet code:

      package ws;

       

      import javax.jws.WebMethod;
      import javax.jws.WebService;

       

      @WebService
      public class MyWebServiceServlet {

       

          @WebMethod
          public void hello() {
              System.out.println("MyWebServiceServlet.hello()");
          }

      };

       

      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.4">

       

          <servlet>
              <servlet-name>MyWebService</servlet-name>
              <servlet-class>ws.MyWebServiceServlet</servlet-class>
          </servlet>

       

          <servlet-mapping>
              <servlet-name>MyWebService</servlet-name>
              <url-pattern>/MyWebService</url-pattern>
          </servlet-mapping>

      </web-app>

       

      Getting web service address: http://127.0.0.1:8080/sod-ws/MyWebService?wsdl in web browser end with exception:

      11:07:03,218 ERROR [[MyWebService]] Allocate exception for servlet MyWebService
      java.lang.ClassCastException: ws.MyWebServiceServlet cannot be cast to javax.servlet.Servlet
              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)
              at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:619)

       

       

       

      When I rename servlet to MyWebService everything works fine... I thing it's a bug.

       

      I've tested in on windows platform, Java 6