[jboss-user] [JBoss Web Services CXF] - ClassCastException when initializing CXFServlet

Alessio Soldano do-not-reply at jboss.com
Tue Jun 8 05:54:25 EDT 2010


Alessio Soldano [http://community.jboss.org/people/alessio.soldano%40jboss.com] replied to the discussion

"ClassCastException when initializing CXFServlet"

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

--------------------------------------------------------------
Generally speaking, embedding the cxf libs in your webapp when using the jbossws-cxf stack is likely to give you major headaches with classloading isolation requirements. You'd better leverage the CXF that already comes from the AS. Btw, you can install jbossws-cxf 3.3.0 (beware of JBWS-3048) or jbossws-cxf-3.3.1 (being released today or tomorrow), which come with more recent Apache CXF versions (2.2.8 / 2.2.9).

> Kyle Bober wrote:
> 
> Hello all,
>    I am running into the same issue as posted above. The onbly diffrence is that we are using the 'org.springframework.web.context.ContextLoaderListener' in our web.xml. I am running JBoss 5.1.0 with EAR classloading isolation set to true. We are also running JBossWS Apache CXF 3.2.0. Our application is using Spring 2.5.6 and we run into the same error:
> 
> 13:00:40,562 ERROR [[/ChannelService]] StandardWrapper.Throwable
> java.lang.ClassCastException: org.jboss.spring.vfs.context.VFSXmlWebApplicationContext cannot be cast to java.lang.Exception
>     at org.apache.cxf.transport.servlet.CXFServlet.loadSpringBus(CXFServlet.java:96)
>     at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:70)
>     at org.jboss.wsf.stack.cxf.CXFServletExt.loadBus(CXFServletExt.java:100)
>     at org.apache.cxf.transport.servlet.AbstractCXFServlet.init(AbstractCXFServlet.java:90)
>     at org.jboss.wsf.stack.cxf.CXFServletExt.init(CXFServletExt.java:77)
my guess here is that you're problem comes from the VFSXmlWebApplicationContext coming from a different classloader, not the one that also loaded the CXF stuff. The CXFServlet does something like this around line 96:

Object ctxObject = svCtx.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
if (ctxObject instanceof ApplicationContext) {
   ctx = (ApplicationContext) ctxObject;
} else if (ctxObject != null) {
   // it should be a runtime exception                
   Exception ex = (Exception) ctxObject; // <-- line 96
   throw new ServletException(ex);
}   


so I *think* the VFS version of Spring application context (Snowdrop?) is not seen as an ApplicationContext, causing in the else branch of the if being executed and hence the error you see.
You'd probably need to better debug what's happening there, and depending on that you might find a workaround for your usecase.

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

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

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/20100608/a741acba/attachment.html 


More information about the jboss-user mailing list