3 Replies Latest reply on Apr 21, 2017 10:27 AM by Anup Dey

    Loading Spring Module in JBoss EAP through Apache CXF module

    Sergio Polo Newbie

      I have a question regardind behavior JBoss EAP has when loading static modules.

       

      In particular, my question is that what happens when I need Apache CXF to use in my webapp and integrate it with Spring, and I have two Spring modules created in JBoss, each one with different Spring version. See:

      Version: 3.2.18.RELEASE created at: {JBOSS_ROOT}\modules\org\springframework\spring\3.2.18.RELEASE (for my application):

       

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="org.springframework.spring" slot="3.2.18.RELEASE">
           <resources>
                <resource-root path="aopalliance-1.0.jar"/>
                <resource-root path="spring-aop-3.2.18.RELEASE.jar"/>    
                <resource-root path="spring-beans-3.2.18.RELEASE.jar"/>
                <resource-root path="spring-context-3.2.18.RELEASE.jar"/>
                <!-- .... --->
           </resources>
           <dependencies>
                <module name="org.apache.commons.logging"/>
                <module name="javaee.api"/>
                <module name="org.jboss.vfs"/>
           </dependencies>
      </module>
      

       

      And

       

      Version: 4.2.4.RELEASE (for other application already deployed in JBoss):

      as main: {JBOSS_ROOT}\modules\org\springframework\spring\main (for another application already deployed):

       

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="org.springframework.spring">
           <resources>
                <resource-root path="aopalliance-1.0.jar"/>
                <resource-root path="spring-aop-4.2.4.RELEASE.jar"/>    
                <resource-root path="spring-beans-4.2.4.RELEASE.jar"/>
                <resource-root path="spring-context-4.2.4.RELEASE.jar"/>
                <!-- .... --->
           </resources>
           <dependencies>
                <module name="org.apache.commons.logging"/>
                <module name="javaee.api"/>
                <module name="org.jboss.vfs"/>
           </dependencies>
      </module>
      

       

      However built-in Apache CXF module within JBoss depends on Spring Module, but not especifies version (so takes `main`):

       

           <dependencies>
                <module name="org.springframework.spring" optional="true">
                     <imports>
                          <include path="META-INF"/>
                     </imports>
                </module>
           </dependencies>
      

       

       

      How can I use Apache CXF in my application but also using my Spring version?. I tried with jboss-deployment-structure.xml like this:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
           <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
           <deployment>
                <exclude-subsystems>
                     <subsystem name="jaxrs"/>
                     <subsystem name="webservices"/>
                </exclude-subsystems>
           </deployment>
           <sub-deployment name="myapp.war">
                <local-last value="true"/>
                <dependencies>
                     <module name="org.apache.cxf"/>
                     <module name="org.apache.cxf.impl" meta-inf="import"/>
                     <module name="org.springframework.spring" meta-inf="import" slot="3.2.18.RELEASE"/>
                     <module name="org.aspectj" />
                     <module name="org.slf4j"/>
                </dependencies>
          </sub-deployment>
      </jboss-deployment-structure>
      

       

      Is there another workaround? (I've thought modify module.xml from apache cxf to point my version, but it causes to stop working the other application, obviously)

       

      Environment: JBoss EAP 6.4

       

      Thanks!

        • 1. Re: Loading Spring Module in JBoss EAP through Apache CXF module
          Anup Dey Apprentice

          CXF will be considered part of your application code. Its recommend you utilize the version of CXF packaged with JBoss release because it has been specifically tested with all the other components in JBoss to ensure interoperability.

          Make sure all JBossWS and CXF modules are excluded from the application component using the CXF jars. This would be done in either a jboss-deployment-structure.xml for deployments or in module.xml of the relevant module if the code is found in a shared JBoss module.

          JBoss EAP 6 is required by the JavaEE 6 specification to provide a JAX-RS implementation, which is done via RESTEasy. It is recommended that you do not package your own JAX-RS implementation as that is an antipattern.  If you must use and package a different JAX-RS implementation it will be considered part of your application.

          • 2. Re: Loading Spring Module in JBoss EAP through Apache CXF module
            Sergio Polo Newbie

            Yes, I am testing with different configurations and I try to exclude subsystem for test.

             

            My actual jboss-deployment-structure-xml file is:

             

            1. <?xml version="1.0" encoding="UTF-8"?> 
            2. <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> 
            3.      <ear-subdeployments-isolated>false</ear-subdeployments-isolated> 
            4.      <sub-deployment name="myapp.war"> 
            5.           <local-last value="true"/> 
            6.           <dependencies> 
            7.                <module name="org.apache.cxf"/> 
            8.                <module name="org.apache.cxf.impl" meta-inf="import"/> 
            9.                <module name="org.springframework.spring" meta-inf="import" slot="3.2.18.RELEASE"/> 
            10.                <module name="org.quartz-scheduler.quartz" slot="1.8.3" /> 
            11.                <module name="org.aspectj" slot="1.6.1"/> 
            12.                <module name="org.slf4j"/> 
            13.           </dependencies> 
            14.     </sub-deployment> 
            15. </jboss-deployment-structure>

             

            My question is how I can tell Apache CXF to use Spring module version: 3.2.18.RELEASE, and not "main" version (that actually is 4.2.4.VERSION).

            • 3. Re: Loading Spring Module in JBoss EAP through Apache CXF module
              Anup Dey Apprentice

              The Apache CXF client and endpoint configuration as explained in the Apache CXF official user guide is heavily based on Spring. Apache CXF basically parses Spring cxf.xml descriptors; those may contain any basic bean plus specific ws client and endpoint beans which CXF has custom parsers for. Apache CXF can be used to deploy webservice endpoints on any servlet container by including its libraries in the deployment; in such a scenario Spring basically serves as a convenient configuration option, given direct Apache CXF API usage won't be very handy. Similar reasoning applies on client side, where a Spring based descriptor offers a shortcut for setting up Apache CXF internals.

              This said, nowadays almost any Apache CXF functionality can be configured and used through direct API usage, without Spring. As a consequence of that and given the considerations in the sections below, the JBossWS integration with Apache CXF does not rely on Spring descriptors.