Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-3556

Migration Docs: module.xml resource-root takes priority over dependencies

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.0.ER6
    • None
    • Documentation
    • None

      If the same class is container in 2 modules and 1 module depends on the other. In EAP 7, the class in the resource-root will take precedence over the class coming from the dependency. This is a change from EAP 6 where the class from the dependency would take precedence over the one in the resource-root.

      Attaching test-overlay.zip which can be unzipped onto EAP 6 or EAP 7
      unzip -d jboss-eap-7/ test-overlay.zip

      Start the server and it will log a message indicating which took priority.

      EAP 7:

      com.jboss.examples.servlet.Servlet - Test: Resource Root loaded from: jar:file:/tmp/jboss-eap-7.0/modules/test/main/resource-root.jar!/
      

      EAP 6:

      com.jboss.examples.servlet.Servlet - Test: Dependency loaded from: jar:file:/tmp/jboss-eap-6.4/modules/test/dependencies/main/dependency.jar!/
      
      <module xmlns="urn:jboss:module:1.1" name="test">
          <resources>
              <resource-root path="resource-root.jar"/>
          </resources>
          <dependencies>
              <module name="test.dependencies" export="true"/>
          </dependencies>
      </module>
      
      <module xmlns="urn:jboss:module:1.1" name="test.dependencies">
          <resources>
              <resource-root path="dependency.jar"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
          </dependencies>
      </module>
      

      Side note when classes are duplicate in modules, it is important to ensure that there is only 1 class visible to a deployment or module otherwise ClassCastException, LinkageError and other Classloading errors can occur.

      A module can prevent exporting of classes using exports (exclude/include) as shown below:

      <module xmlns="urn:jboss:module:1.1" name="org.apache.santuario.xmlsec">
          <exports>
              <exclude path="javax/**"/>
          </exports>
      ...
      </module>
      

      A module can also include/exclude classes from a module it depends on such as:

      <module xmlns="urn:jboss:module:1.1" name="org.picketlink.federation">
      ...
              <module name="org.apache.santuario.xmlsec">
                  <imports>
                      <exclude path="javax/*"/>
                  </imports>
              </module>
      ...
              <module name="org.picketlink.config">
                  <imports>
                      <exclude-set>
                        <path name="org.picketlink.config.idm"/>
                      </exclude-set>
                  </imports>
              </module>
      

              sgilda_jira Sande Gilda (Inactive)
              rhn-support-bmaxwell Brad Maxwell
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: