<!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">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;">
    ClassCastException when initializing CXFServlet
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/alessio.soldano%40jboss.com">Alessio Soldano</a> in <i>JBoss Web Services CXF</i> - <a href="http://community.jboss.org/message/546708#546708">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>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).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><blockquote class="jive-quote"><p>Kyle Bober wrote:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Hello all,</p><p>&#160;&#160; 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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>13:00:40,562 ERROR [[/ChannelService]] StandardWrapper.Throwable<br/>java.lang.ClassCastException: org.jboss.spring.vfs.context.VFSXmlWebApplicationContext cannot be cast to java.lang.Exception<br/>&#160;&#160;&#160; at org.apache.cxf.transport.servlet.CXFServlet.loadSpringBus(CXFServlet.java:96)<br/>&#160;&#160;&#160; at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:70)<br/>&#160;&#160;&#160; at org.jboss.wsf.stack.cxf.CXFServletExt.loadBus(CXFServletExt.java:100)<br/>&#160;&#160;&#160; at org.apache.cxf.transport.servlet.AbstractCXFServlet.init(AbstractCXFServlet.java:90)<br/>&#160;&#160;&#160; at org.jboss.wsf.stack.cxf.CXFServletExt.init(CXFServletExt.java:77)</p></blockquote><p>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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">Object ctxObject = svCtx.getAttribute(<font color="red">"org.springframework.web.context.WebApplicationContext.ROOT"</font>);
<font color="navy"><b>if</b></font> (ctxObject <font color="navy"><b>instanceof</b></font> ApplicationContext) <font color="navy">{</font>
&#160;&#160; ctx = (ApplicationContext) ctxObject;
<font color="navy">}</font> <font color="navy"><b>else</b></font> <font color="navy"><b>if</b></font> (ctxObject != <font color="navy"><b>null</b></font>) <font color="navy">{</font>
&#160;&#160; <font color="darkgreen">// it should be a runtime exception&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font>
&#160;&#160; Exception ex = (Exception) ctxObject; <font color="darkgreen">// &lt;-- line 96</font>
&#160;&#160; <font color="navy"><b>throw</b></font> <font color="navy"><b>new</b></font> ServletException(ex);
<font color="navy">}</font>&#160;&#160; 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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.</p><p>You'd probably need to better debug what's happening there, and depending on that you might find a workaround for your usecase.</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/546708#546708">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services CXF at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2046">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>