[jboss-user] [JBoss Web Services] - POJO web service cannot be cast to javax.servlet.Servlet

Paweł Stokowiec do-not-reply at jboss.com
Tue Jun 29 05:14:48 EDT 2010


Paweł Stokowiec [http://community.jboss.org/people/p100] created the discussion

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

To view the discussion, visit: http://community.jboss.org/message/550140#550140

--------------------------------------------------------------
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:
{code}java.lang.ClassCastException: package.name.MyWsServlet cannot be cast to javax.servlet.Servlet{code}

Pojo servlet code:
{code}
package ws;

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

@WebService
public class MyWebServiceServlet {

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

web.xml
{code}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns=" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd 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>
{code}

Getting web service address:  http://127.0.0.1:8080/sod-ws/MyWebService?wsdl http://127.0.0.1:8080/sod-ws/MyWebService?wsdl in web browser end with exception:
{code}
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)
{code}


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

I've tested in on windows platform, Java 6

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/550140#550140]

Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100629/859cd540/attachment-0001.html 


More information about the jboss-user mailing list