[jboss-user] [JBoss Web Services CXF] - ClassCastException: MyImpl cannot be cast to javax.servlet.Servlet

Chet Vora do-not-reply at jboss.com
Mon Jun 14 14:20:39 EDT 2010


Chet Vora [http://community.jboss.org/people/cvoraintuit] created the discussion

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

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

--------------------------------------------------------------
Hi all,

I'm trying to get the sample application from  http://www.ibm.com/developerworks/java/library/j-jws13.html 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 http://www.springframework.org/schema/beans'
  xmlns:xsi=' http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance'
  xmlns:beans=' http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans'
  xmlns:jaxws=' http://cxf.apache.org/jaxws http://cxf.apache.org/jaxws'
  xsi:schemaLocation=' http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans/spring-beans.xsd
   http://cxf.apache.org/jaxws http://cxf.apache.org/jaxws
   http://cxf.apache.org/schemas/jaxws.xsd 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 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 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 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
[http://community.jboss.org/message/547878#547878]

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

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


More information about the jboss-user mailing list