9 Replies Latest reply on Jun 16, 2013 2:14 PM by stephane_jeandeaux

    ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7

    mathewvino

      I have trouble with CXF 2.7.0 in a JBoss AS7 environment. There is a classpath conflict with the RESTEasy Response class:

      Caused by: java.lang.ClassCastException: org.jboss.resteasy.core.ServerResponse cannot be cast to org.apache.cxf.jaxrs.impl.ResponseImpl at org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:975) ...

       

       

       

      Google around and added the following configuration in jboss_deployement_structure.xml file. But no luck I am using jboss7.1.1 as my application server. Any thoughts on this. Thanks for the help

       

      <sub-deployment name="tfnmgr.war">

                  <exclusions>

                   <module name="org.jboss.resteasy.resteasy-atom-provider"/>

                  <module name="org.jboss.resteasy.resteasy-cdi"/>

                  <module name="org.jboss.resteasy.resteasy-jaxrs"/>

                  <module name="org.jboss.resteasy.resteasy-jaxb-provider"/>

                  <module name="org.jboss.resteasy.resteasy-jackson-provider"/>

                                    <module name="org.jboss.resteasy.resteasy-jettison-provider"/>

                                    <module name="org.jboss.resteasy.resteasy-yaml-provider"/>

                                    <module name="org.jboss.as.webservices.*"/>

                  <module name="org.jboss.ws.*" />

                                    <module name="org.jboss.resteasy.resteasy-jsapi"/>

                  <module name="org.jboss.resteasy.resteasy-multipart-provider"/>

                  <module name="org.jboss.resteasy.async-http-servlet-30"/>

                          </exclusions>

                </sub-deployment>

        • 1. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
          vrlgohel

          You need to disable the same like this,

           

          <?xml version="1.0" encoding="UTF-8"?>
          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
            <deployment>
              <exclude-subsystems>
                <subsystem name="jaxrs" />
                <subsystem name="webservices" />
              </exclude-subsystems>
            </deployment>
          </jboss-deployment-structure>

          • 2. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
            mathewvino

            Thanks Viral for the quick response. I tried with this but the problem is I am using JBOSS7.1.1 and i am getting like the following error

            Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]

            Message: Unexpected element '{urn:jboss:deployment-structure:1.2}jboss-deployment-structure'.

             

            Is it something like I need to upgrade my jboss to the latest version.

             

            Thanks for the help

            • 3. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
              vrlgohel

              Hi Vinod,

               

              This depends on the namespaces configured in module.xml for jax-rs and cxf.

              For example, in $JBOSS_HOME/modules/org/apache/cxf/main/module.xml, the xmlns points to  'urn:jboss:module:1.1', then you would need to have the same in your jboss-deployment-structure.xml.

               

              Like this, <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">.

               


              Can you please try this out and let me know the results ?

              • 4. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
                mathewvino

                Thanks Viral,

                 

                I think I tried  and I am getting the following error .The error says <exclude-subsystems> is not supported in 7.1.1

                 

                15:59:00,388 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."tfn-ear-1.4.0-SNAPSHOT.ear".STRUCTURE: org.jboss.msc.service.StartExce

                ption in service jboss.deployment.unit."tfn-ear-1.4.0-SNAPSHOT.ear".STRUCTURE: Failed to process phase STRUCTURE of deployment "tfn-ear-1.4.0-SNAPSHOT.ear"

                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_02]

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_02]

                        at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_02]

                Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Error loading jboss-structure.xml from C:\jboss-as-7.1.1.Final\standalone\tmp\vfs\tempdcc7875d15f8c489\content-fe7468c559dc

                5ef\contents\META-INF\jboss-deployment-structure.xml

                        at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:277) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                        at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:249) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                        at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:134) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                        ... 5 more

                Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,9]

                Message: Unexpected content of type 'element start' named '{urn:jboss:deployment-structure:1.1}exclude-subsystems'

                        at org.jboss.as.server.deployment.module.descriptor.JBossDeploymentStructureParser11.unexpectedContent(JBossDeploymentStructureParser11.java:1098) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                • 5. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
                  vrlgohel

                  Are you get that exception when the application is deployed or invoking it ?

                  • 6. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
                    jmalpica

                    Hi all,

                     

                    I am facing the same problem and I am really stuck with that. Did you finally get a solution?

                     

                    Thank you.

                    • 7. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
                      chaohuis

                      jboss-eap-6.1.0.Beta&jboss-as-7.1.1.Final.

                       

                      just one solution,not recommend.

                       

                      1.comment

                      <!--

                              <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>-->

                      and

                      <!--

                              <extension module="org.jboss.as.jaxrs"/>-->

                       

                      in standalone.xml

                      ---

                      2.comment

                      <!--

                              <module name="javax.ws.rs.api" export="true"  services="export"/>-->

                       

                      in $JBOSS_HOME/modules/system/layers/base/javaee/api/main/module.xml

                      • 8. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
                        jmalpica

                        Hi chaohui sun,

                         

                        that works fine for me!!!!!!!

                         

                        Thank you very much for your help. 

                        • 9. Re: ClassCastException using CXF 2.7.0 JAX-RS Client in JBoss AS7
                          stephane_jeandeaux

                          Hi Mathew,

                           

                          I have a war and use cxf 2.7.5 and Jboss 7.1.1.Final. That works with jboss-deployment-structure.xml in my web-inf :

                           

                          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

                                    <deployment>

                                              <exclusions>

                                                        <!-- Exclude Version cxf of JBOSS -->

                                                        <module name="org.apache.cxf" />

                                                        <!-- Exclude JAVA EE of JBOSS (javax.ws..) => Add dependency javax.annotation -->

                                                        <module name="javaee.api" />

                           

                           

                                                        <!-- Exclude RestEasy conflict (javax.ws.rs.ext.RunDelegate) -->

                                                        <module name="org.jboss.resteasy.resteasy-atom-provider" />

                                                        <module name="org.jboss.resteasy.resteasy-cdi" />

                                                        <module name="org.jboss.resteasy.resteasy-jackson-provider" />

                                                        <module name="org.jboss.resteasy.resteasy-jaxb-provider" />

                                                        <module name="org.jboss.resteasy.resteasy-jaxrs" />

                                                        <module name="org.jboss.resteasy.resteasy-jettison-provider" />

                                                        <module name="org.jboss.resteasy.resteasy-jsapi" />

                                                        <module name="org.jboss.resteasy.resteasy-multipart-provider" />

                                                        <module name="org.jboss.resteasy.resteasy-yaml-provider" />

                           

                                              </exclusions>

                           

                                              <dependencies>

                                                        <!-- Add javax.annotation.Ressource -->

                                                        <module name="javax.annotation.api" />

                                              </dependencies>

                                    </deployment>

                          </jboss-deployment-structure>