Community

ClassCastException: MyImpl cannot be cast to javax.servlet.Servlet

created by Chet Vora in JBoss Web Services CXF - View the full discussion

Hi all,


I'm trying to get the sample application from http://www.ibm.com/developerworks/java/library/j-jws13.html to work on JBoss Enterprise 5.0.0RC1 with Apache CXF integration (jbossws-cxf-3.2.2.GA).  

 

I could get it to work using CXF servlet (after a few tweaks which took me some time to figure out).

 

But when I try to use the CXF integration using jbossws-cxf.xml, I am running into this error:

 

2010-06-14 14:09:35,595 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cxf-library-username-jboss].[CXFLibrary]] (http-127.0.0.1-8080-1) Allocate exception for servlet CXFLibrary

java.lang.ClassCastException: com.sosnoski.ws.library.cxf.CXFLibraryImpl cannot be cast to javax.servlet.Servlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1006)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:777)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    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:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)

 

These are the changes I made to use the JBoss-CXF integration.

 

* removed cxf-servlet.xml from war WEB-INF and replaced with jbossws-cxf.xml

 

* changed web.xml to this based on the testcases inside of jbossws-cxf-src-dist

 

   <servlet>
      <servlet-name>CXFLibrary</servlet-name>
      <servlet-class>com.sosnoski.ws.library.cxf.CFXLibraryImpl</servlet-class>
   </servlet>
   <servlet-mapping>
      <servlet-name>CXFLibrary</servlet-name>
      <url-pattern>/*</url-pattern>
   </servlet-mapping>

* commented out all references to CxfServlet from web.xml

 

This is what my jbossws-cxf.xml looks like:

 

<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'>

 

  <!-- one or more jaxws:endpoint POJO declarations -->
  <jaxws:endpoint
    id='Processor'
    address='http://localhost:8080/cxf-library-username'
    wsdlLocation="WEB-INF/wsdl/library-username.wsdl"
    implementor='com.sosnoski.ws.library.cxf.CXFLibraryImpl'>
      <jaxws:properties>
        <entry key="ws-security.callback-handler"
            value="com.sosnoski.ws.library.cxf.ServerCallback"/>
      </jaxws:properties>

 

    <jaxws:invoker>
      <bean class='org.jboss.wsf.stack.cxf.InvokerJSE'/>
    </jaxws:invoker>
  </jaxws:endpoint>

 

</beans>

 

 

My impl POJO is annotated as such (this works with cxf-servlet.xml and i didn't change it for Jbossws-cxf ):

 

@javax.jws.WebService(endpointInterface="com.sosnoski.ws.library.cxf.Library",
    portName="library", targetNamespace="http://ws.sosnoski.com/library/wsdl",
        wsdlLocation = "WEB-INF/wsdl/library-username.wsdl",
    serviceName="CXFLibrary")

 

and this is how the wsdl references it.

 

<wsdl:service name="CXFLibrary">

 

    <wsdl:port binding="wns:LibrarySoapBinding" name="library">
      <wsdlsoap:address location="http://localhost:8080/cxf-library-username"/>
    </wsdl:port>

 

  </wsdl:service>

 

Let me know if I can provide any more details. I'm really bummed as to why it doesn't work.

 

Thanks in advance for your help.

CV

Reply to this message by going to Community

Start a new discussion in JBoss Web Services CXF at Community