3 Replies Latest reply on Nov 2, 2015 12:38 PM by jaysensharma

    Explanation of modules "export" and "import" elements

    juan_a_velez

      OSX 10.10 JBoss EAP 6.4.0P3 JDK 1.7.0_75

       

      I have an ear which includes both an ejb jar and a war file. The war file's lib directoy includes spring 2.5.6 libraries. I also need both the war and ejb jar to access module xyz. module xyz has resource paths that include spring 4.1.0 libraries. I am using false for classloading isolation

       

      <subsystem xmlns="urn:jboss:domain:ee:1.2">
              <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

       

      The problem I have is that when the war starts it is loading spring but instead of seeing its own libraries it is seeing the ones from the xyz module

       

      I am trying to "exclude" the spring code when adding the xyx module as a dependency in my jboss-deployment-structure with no luck

       

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

      <jboss-deployment-structure>

        <deployment>

          <dependencies>

            <module name="com.module.xyz" export="true" />

          </dependencies>

        </deployment>

      </jboss-deployment-structure>

       

      Module xyz

       

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

       

      <module xmlns="urn:jboss:module:1.1" name="com.module.xyz">

          <resources>

              <resource-root path="something-1.0.jar"/>

              <resource-root path="other-something-1.0.jar"/>

              <resource-root path="spring-aop-4.1.0.RELEASE.jar"/>

              <resource-root path="spring-beans-4.1.0.RELEASE.jar"/>

              <resource-root path="spring-context-4.1.0.RELEASE.jar"/>

              <resource-root path="spring-core-4.1.0.RELEASE.jar"/>

              <resource-root path="spring-expression-4.1.0.RELEASE.jar"/>

              <resource-root path="spring-jdbc-4.1.0.RELEASE.jar"/>

              <resource-root path="spring-tx-4.1.0.RELEASE.jar"/>

          </resources>

       

          <dependencies>

              <module name="javax.api"/>

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

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

              <module name="sun.jdk"/>

          </dependencies>

      </module>

       

      Any ideas on how to do this?

       

      Also, why is that I need to set export="true" in the jboss-deployment-structure.xml?

        • 1. Re: Explanation of modules "export" and "import" elements
          wdfink

          You can have different settings for every subdeployment within the jboss-deployment-structure.

          So you can use it for the war and exclude the module explicit.

          • 2. Re: Explanation of modules "export" and "import" elements
            juan_a_velez

            Thanks for your reply. But what I would like is an explanation/samples of how the export/import XML elements are used and how they work. Having said this, I had to dig into the JBoss modules code and was able to see how they are used but at the end I didn't understand the following:

             

            When using a jboss-deployment-structure.xml, it seems all declared dependencies (plus the jars in the ear's lib folder) end up being treated as a single module, to which the sub-deployments have access. But if the dependencies inside this jboss-deployment-structure.xml don't have "export=true", then they won't be seen by the "sub-deployments". This is the part I don't understand and goes (at least in my understanding) against what the explanation in (Class Loading in AS7 - JBoss AS 7.1 - Project Documentation Editor) says.

             

            I would greatly appreciate if the above "contradiction" can be explained.

            • 3. Re: Explanation of modules "export" and "import" elements
              jaysensharma

              Hello Juan,

                   As an example Consider a scenario where an EAR has the following modules. "EJBOne.jar", "EJBTwo.jar", "WebOne.war" and "WebTwo.war" all those submodules need access to the same module "my.test.module"

               

               

              OPTION-1). Defining dependencies to each individual sub-deployment will make it available to all the individual sub-deployments .

               

                 <jboss-deployment-structure>
                      <sub-deployment name="EJBOne.jar">
                          <dependencies>
                              <module name="my.test.module"/>
                          </dependencies>
                      </sub-deployment>
                      <sub-deployment name="EJBTwo.jar">
                          <dependencies>
                              <module name="my.test.module"/>
                          </dependencies>
                      </sub-deployment>       
                      <sub-deployment name="WebOne.war">
                          <dependencies>
                              <module name="my.test.module"/>
                          </dependencies>
                      </sub-deployment>
                      <sub-deployment name="WebTwo.war">
                          <dependencies>
                              <module name="my.test.module"/>
                          </dependencies>
                      </sub-deployment>       
                 </jboss-deployment-structure>
              

               

              OPTION-2). Or Else using  [export="true"] can simplify this thing as following

               

                 <jboss-deployment-structure>
                     <deployment>
                          <dependencies>     
                             <module name="my.test.module" export="true" />  
                          </dependencies>
                     </deployment>
                 </jboss-deployment-structure>