13 Replies Latest reply on Feb 24, 2012 8:03 AM by marc.van.andel

    ClassCastException when initializing CXFServlet

      I am currently migrating existing web projects from JBoss AS 4.0.3 to 4.3.2.
      Our web projects utilize Spring 2.5.6.SEC01 and offer WebServices using Apache CXF 2.2.3.

      Policies make us to use JBoss WS CXF Stack version 3.1.0.
      Deployment on JBoss 4.3.2 gives me an ClassCastExcpetion when the CXF Servlet is initialized:

      12:10:57,796 ERROR [[/fixwerte]] StandardWrapper.Throwable
      java.lang.ClassCastException:
      org.springframework.web.context.support.XmlWebApplicationContext 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.apache.cxf.transport.servlet.AbstractCXFServlet.init(
      AbstractCXFServlet.java:79)
       at org.apache.catalina.core.StandardWrapper.loadServlet(
      StandardWrapper.java:1161)
       at org.apache.catalina.core.StandardWrapper.load(
      StandardWrapper.java:981)
       at org.apache.catalina.core.StandardContext.loadOnStartup(
      StandardContext.java:4071)
       at org.apache.catalina.core.StandardContext.start(
      StandardContext.java:4375)
       at org.apache.catalina.core.ContainerBase.addChildInternal(
      ContainerBase.java:790)
       at org.apache.catalina.core.ContainerBase.addChild(
      ContainerBase.java:770)
       at org.apache.catalina.core.StandardHost.addChild(
      StandardHost.java:553)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
      NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(
      BaseModelMBean.java:296)
       at org.jboss.mx.server.RawDynamicInvoker.invoke(.
      RawDynamicInvoker.java:164)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.apache.catalina.core.StandardContext.init(
      StandardContext.java:5312)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
      NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(
      BaseModelMBean.java:296)
       at org.jboss.mx.server.RawDynamicInvoker.invoke(.
      RawDynamicInvoker.java:164)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(
      TomcatDeployer.java:301)
       at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(
      TomcatDeployer.java:104)
       at org.jboss.web.AbstractWebDeployer.start(
      AbstractWebDeployer.java:375)
       at org.jboss.web.WebModule.startModule(WebModule.java:83.)
       at org.jboss.web.WebModule.startService(WebModule.java:61.)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(
      ServiceMBeanSupport.java:289)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(
      ServiceMBeanSupport.java:245)
       at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(
      ReflectedDispatcher.java:155.)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(
      AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(
      ServiceController.java:978)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(
      ServiceController.java:417)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(
      ReflectedDispatcher.java:155.)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(
      AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy44.start(Unknown Source)
       at org.jboss.web.AbstractWebContainer.start(
      AbstractWebContainer.java:466)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
      NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(
      ReflectedDispatcher.java:155.)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(
      AbstractInterceptor.java:133.)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(
      ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.interceptor.DynamicInterceptor.invoke(
      DynamicInterceptor.java:97)
       at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(
      InterceptorServiceMBeanSupport.java:238)
       at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(
      DeployerInterceptor.java:85.)
       at org.jboss.deployment.SubDeployerInterceptorSupport
      $XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
       at org.jboss.deployment.SubDeployerInterceptor.invoke(
      SubDeployerInterceptor.java:95)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(
      AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy45.start(Unknown Source)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
       at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(
      ReflectedDispatcher.java:155.)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(
      AbstractInterceptor.java:133.)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(
      ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(
      AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy9.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(
      URLDeploymentScanner.java:421)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(
      URLDeploymentScanner.java:634)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner
      $ScannerThread.doScan(AbstractDeploymentScanner.java:263)
       at
      org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(.
      AbstractDeploymentScanner.java:336)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(
      ServiceMBeanSupport.java:289)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(
      ServiceMBeanSupport.java:245)
       at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(
      ReflectedDispatcher.java:155.)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(
      AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(
      ServiceController.java:978)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(
      ServiceController.java:417)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(
      ReflectedDispatcher.java:155.)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(
      AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:304)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
      NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(
      ReflectedDispatcher.java:155.)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(
      AbstractInterceptor.java:133.)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(
      ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(
      AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(
      MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy5.deploy(Unknown Source)
       at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
       at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
       at org.jboss.Main.boot(Main.java:200.)
       at org.jboss.Main$1.run(Main.java:508.)
       at java.lang.Thread.run(Thread.java:619)
      


      As far as I know, the CXF Stack utilizes Spring 2.5.5 components. Could this cause the problems? Using Spring 2.5.5 in the web application does not change anything.
      Also deploying plain web services without a web application using Spring works under our environment.

        • 1. Re: ClassCastException when initializing CXFServlet
          jim.ma

          Can you provide more information ? for example the web.xml or what is packaged in your war file ?

          • 2. Re: ClassCastException when initializing CXFServlet

            Thanks for the quick response, of course I can provide further information:

            web.xml:

            <?xml version="1.0" ?>
            <web-app xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             version="2.5">
            
             <display-name>My Project</display-name>
             <welcome-file-list>
             <welcome-file>index.jsp</welcome-file>
             </welcome-file-list>
            
             <context-param>
             <param-name>contextConfigLocation</param-name>
             <param-value>
             myApplicationContext.xml
             </param-value>
             </context-param>
            
             <!-- Listener -->
             <listener>
             <listener-class>
             org.springframework.web.context.ContextLoaderListener
             </listener-class>
             </listener>
            
             <listener>
             <listener-class>
             my.example.MyServletContextListener
             </listener-class>
             </listener>
            
             <!-- CXF -->
             <!-- Not the standard JbossWS way, but same results -->
             <servlet>
             <servlet-name>CXFServlet</servlet-name>
             <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
             <init-param>
             <param-name>config-location</param-name>
             <param-value>/WEB-INF/cxf-servlet.xml</param-value>
             </init-param>
             <load-on-startup>1</load-on-startup>
             </servlet>
            
             <servlet-mapping>
             <servlet-name>CXFServlet</servlet-name>
             <url-pattern>/services/cxf/*</url-pattern>
             </servlet-mapping>
            
             <!-- Seam -->
             <listener>
             <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
             </listener>
            
             <filter>
             <filter-name>Seam Filter</filter-name>
             <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
             </filter>
            
             <filter-mapping>
             <filter-name>Seam Filter</filter-name>
             <url-pattern>/*</url-pattern>
             </filter-mapping>
            
             <servlet>
             <servlet-name>Seam Resource Servlet</servlet-name>
             <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
             </servlet>
            
             <servlet-mapping>
             <servlet-name>Seam Resource Servlet</servlet-name>
             <url-pattern>/seam/resource/*</url-pattern>
             </servlet-mapping>
            
             <!-- Facelets development mode (disable in production) -->
            
             <context-param>
             <param-name>facelets.DEVELOPMENT</param-name>
             <param-value>true</param-value>
             </context-param>
            
             <!-- JSF -->
            
             <context-param>
             <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
             <param-value>.xhtml</param-value>
             </context-param>
            
             <servlet>
             <servlet-name>Faces Servlet</servlet-name>
             <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
             <load-on-startup>1</load-on-startup>
             </servlet>
            
             <servlet-mapping>
             <servlet-name>Faces Servlet</servlet-name>
             <url-pattern>*.seam</url-pattern>
             </servlet-mapping>
            
             <security-constraint>
             <display-name>Restrict raw XHTML Documents</display-name>
             <web-resource-collection>
             <web-resource-name>XHTML</web-resource-name>
             <url-pattern>*.xhtml</url-pattern>
             </web-resource-collection>
             <auth-constraint />
             </security-constraint>
            
            </web-app>
            
            
            


            cxf-servlet.xml:

            <?xml version="1.0" encoding="UTF-8"?>
            <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:jaxws="http://cxf.apache.org/jaxws"
             xmlns:cxf="http://cxf.apache.org/core"
             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
             http://cxf.apache.org/core
             http://cxf.apache.org/schemas/core.xsd"
             default-autowire="byName">
            
             <!-- Load CXF modules from cxf.jar -->
             <import resource="classpath:META-INF/cxf/cxf.xml" />
             <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
             <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
            
             <!-- Enable message logging using the CXF logging feature -->
            
             <cxf:bus>
             <cxf:features>
             <cxf:logging />
             </cxf:features>
             </cxf:bus>
            
             <!-- Service endpoint -->
            
             <jaxws:endpoint id="myService"
             implementor="my.example.cxf.SOAPReceiverServiceImpl"
             address="/myService" />
            
            </beans>
            


            WAR-structure:

            example.war
             META-INF
             pages
             WEB-INF
             classes
             ...
             lib
             ant-antlr.jar
             commons-beanutils.jar
             commons-digester.jar
             commons-lang-2.4.jar
             core.jar
             dozer-4.4.1.jar
             drools-compiler.jar
             drools-core.jar
             hibernate-3.3.1.GA.jar
             janino.jar
             jboss-el.jar
             jboss-seam.jar
             jboss-seam-debug.jar
             jboss-seam-ui.jar
             jsf-facelets.jar
             jxl.jar
             slf4j-api-1.5.8.jar
             slf4j-jcl-1.5.8.jar
             spring-2.5.6.SEC01.jar
             components.xml
             cxf-servlet.xml
             faces-config.xml
             jboss-web.xml (empty)
             pages.xml
             web.xml
            



            • 3. Re: ClassCastException when initializing CXFServlet
              jim.ma

               

              "paulhuemer" wrote:
              I am currently migrating existing web projects from JBoss AS 4.0.3 to 4.3.2.
              Our web projects utilize Spring 2.5.6.SEC01 and offer WebServices using Apache CXF 2.2.3.
              As far as I know, the CXF Stack utilizes Spring 2.5.5 components. Could this cause the problems? Using Spring 2.5.5 in the web application does not change anything.

              Thanks for your clear information. The Spring 2.5.6.SEC01 in your war file cause this problem . Try to set the classloading isolation in the jboss-web.xml and look at if cxf can work with Spring 2.5.6 SEC01.

              • 4. Re: ClassCastException when initializing CXFServlet

                I tried to enable classloading isolation for the WAR, but neither of these two configurations worked out. Is there any other way I am unaware of how to achieve classloading isolation?

                <!DOCTYPE jboss-web PUBLIC
                 "-//JBoss//DTD Web Application 4.2//EN"
                 "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
                <jboss-web>
                 <class-loading>
                 <loader-repository.>
                 at.my.example:archive=fixwerte.war
                 <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                 </loader-repository>
                 </class-loading>
                </jboss-web>
                


                According to http://www.jboss.org/community/wiki/ClassLoadingconfiguration:

                <!DOCTYPE jboss-web PUBLIC
                 "-//JBoss//DTD Web Application 4.2//EN"
                 "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
                <jboss-web>
                 <loader-repository.>
                 at.my.example:archive=fixwerte.war
                 <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                 </loader-repository>
                </jboss-web>
                


                • 5. Re: ClassCastException when initializing CXFServlet

                  Any ideas anybody?

                  How can I hide the web-application's Spring-jar from the "built-in" ones in the CXF-stack?

                  • 6. Re: ClassCastException when initializing CXFServlet

                    Well, omitting the stack and bundle Apache CXF 2.2.2 with my webapp (including Spring 2.5.6.SEC01) works for now. By far not my favorite solution altough.

                    • 7. Re: ClassCastException when initializing CXFServlet

                      I had the exact same problem and after trying almost everything including stuff that didn't make sense, I was able to make it work by putting the spring jars (spring.jar, spring-web and spring-webmvc) in the jboss_home/server/{configuration}/lib directory.  I used the 2.5.5 spring jars.  Not being an expert in jboss I don't know if this is the way it's supposed to be but at least it works....

                       

                      Rey

                      • 8. Re: ClassCastException when initializing CXFServlet
                        kyle.bober

                        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)
                            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
                            at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)
                            at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)
                            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421)
                            at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
                            at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
                            at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
                            at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
                            at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            at java.lang.reflect.Method.invoke(Method.java:597)
                            at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
                            at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
                            at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                            at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
                            at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
                            at $Proxy38.start(Unknown Source)
                            at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
                            at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
                            at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
                            at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
                            at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
                            at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                            at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
                            at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                            at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                            at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
                            at org.jboss.system.ServiceController.start(ServiceController.java:460)
                            at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
                            at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
                            at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
                            at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
                            at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
                            at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
                            at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                            at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                            at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
                            at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
                            at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
                            at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
                            at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
                            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
                            at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
                            at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
                            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
                            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
                            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
                            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                            at java.lang.Thread.run(Thread.java:619)
                        13:00:40,562 ERROR [[/ChannelService]] Servlet /ChannelService threw load() exception
                        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)
                            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
                            at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)
                            at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)
                            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421)
                            at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
                            at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
                            at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
                            at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
                            at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            at java.lang.reflect.Method.invoke(Method.java:597)
                            at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
                            at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
                            at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                            at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
                            at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
                            at $Proxy38.start(Unknown Source)
                            at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
                            at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
                            at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
                            at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
                            at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
                            at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                            at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
                            at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                            at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                            at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
                            at org.jboss.system.ServiceController.start(ServiceController.java:460)
                            at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
                            at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
                            at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
                            at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
                            at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
                            at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
                            at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                            at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                            at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                            at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                            at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
                            at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
                            at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
                            at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
                            at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
                            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
                            at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
                            at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
                            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
                            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
                            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
                            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                            at java.lang.Thread.run(Thread.java:619)

                         

                        We ahave an EAR that contains a WAR and a EJB JAR. The WAR is skinny an contains no jar files. All the jar files are included in the lib directory at the root of the EAR file. In the lib directory is the spring.jar whihc is of version 2.5.6. I have attempted turning on class loader isolation via the ear-deployer-jboss-beans.xml file and via the jboss-app.xml file which would then be included in the META-INF folder of the EAR. Both of these approaches did not work. I also tried including the spring.jar in the server/default/lib directory and that did no work either. What is the resolution to this issue??? Any help would be much appreciated!

                         

                        Regards,

                        Kyle S. Bober

                        • 9. Re: ClassCastException when initializing CXFServlet
                          asoldano

                          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.

                          • 10. Re: ClassCastException when initializing CXFServlet
                            kyle.bober

                            Thanks for the response Alessio! I will dig a bit deeper and see what I can come up with!

                             

                            -Kyle

                            • 11. Re: ClassCastException when initializing CXFServlet
                              marc.van.andel

                              I did have the same stacktrace. To solve this I removed the following Spring jars from my .war file:

                               

                              - spring-core

                              - spring-context

                              - spring-beans

                               

                              These are packaged in CXF and therefore provided by the container (obviously when you're using JBoss + CXF).

                               

                              Opinion: Although CXF might be a better or preferred implementation of JAX-WS and easily plugable in JBoss I think the Spring libs suit better as application libraries which should NOT be provided in the container on which an application is deployed but packaged with the application.

                              • 12. Re: ClassCastException when initializing CXFServlet
                                asoldano

                                Marc van Andel wrote:

                                 

                                I did have the same stacktrace. To solve this I removed the following Spring jars from my .war file:

                                 

                                - spring-core

                                - spring-context

                                - spring-beans

                                OK

                                 

                                 

                                 

                                Opinion: Although CXF might be a better or preferred implementation of JAX-WS and easily plugable in JBoss I think the Spring libs suit better as application libraries which should NOT be provided in the container on which an application is deployed but packaged with the application.

                                I see what you mean and that's also one of the reasons why on AS 6 / 7 Spring libs are not installed in JBoss Application Server by default. In particular, on AS 7 you should be able to use your Spring based application (not WS) without any limitation related to JBossWS needs. If you want to have your JBossWS-CXF based application use Spring, though, that will need to be installed as a module (org.springframework.spring) so that the Apache CXF module of the AS can "see" it and depend on it.

                                • 13. Re: ClassCastException when initializing CXFServlet
                                  marc.van.andel

                                  Instead of removing the SpringFramework jars from the .war file changing the classloading mechanism serves as a good workaround. Add a file jboss-classloading.xml to the WEB-INF folder with the following content:

                                   

                                  <?xml version="1.0" encoding="UTF-8"?>

                                  <classloading xmlns="urn:jboss:classloading:1.0"

                                                parent-first="false"

                                                domain="DefaultDomain"

                                                top-level-classloader="true"

                                                parent-domain="Ignored"

                                                export-all="NON_EMPTY"

                                                import-all="true">

                                  </classloading>

                                   

                                  (Info provided through Red Hat Support)