<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    POJO web service cannot be cast to javax.servlet.Servlet
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/p100">PaweÅ‚ Stokowiec</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/550140#550140">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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:</p><p>{code}java.lang.ClassCastException: package.name.MyWsServlet cannot be cast to javax.servlet.Servlet{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Pojo servlet code:</p><p>{code}</p><p>package ws;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import javax.jws.WebMethod;<br/>import javax.jws.WebService;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@WebService<br/>public class MyWebServiceServlet {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @WebMethod<br/>&#160;&#160;&#160; public void hello() {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("MyWebServiceServlet.hello()");<br/>&#160;&#160;&#160; }<br/>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>web.xml</p><p>{code}</p><p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br/><span>&lt;web-app xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/j2ee" target="_blank">http://java.sun.com/xml/ns/j2ee</a><span>" xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span><br/><span>&#160;&#160;&#160; xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/j2ee" target="_blank">http://java.sun.com/xml/ns/j2ee</a><span> </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" target="_blank">http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd</a><span>"</span><br/>&#160;&#160;&#160; version="2.4"&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; &lt;servlet&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;servlet-name&gt;MyWebService&lt;/servlet-name&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;servlet-class&gt;ws.MyWebServiceServlet&lt;/servlet-class&gt;<br/>&#160;&#160;&#160; &lt;/servlet&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; &lt;servlet-mapping&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;servlet-name&gt;MyWebService&lt;/servlet-name&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url-pattern&gt;/MyWebService&lt;/url-pattern&gt;<br/>&#160;&#160;&#160; &lt;/servlet-mapping&gt;<br/>&lt;/web-app&gt;</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span>Getting web service address: </span><a class="jive-link-external-small" href="http://127.0.0.1:8080/sod-ws/MyWebService?wsdl" target="_blank">http://127.0.0.1:8080/sod-ws/MyWebService?wsdl</a><span> in web browser end with exception:</span></p><p>{code}</p><p>11:07:03,218 ERROR [[MyWebService]] Allocate exception for servlet MyWebService<br/>java.lang.ClassCastException: ws.MyWebServiceServlet cannot be cast to javax.servlet.Servlet<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:619)</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>When I rename servlet to MyWebService everything works fine... I thing it's a bug.</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've tested in on windows platform, Java 6</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/550140#550140">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>