Uploaded image for project: 'JBoss Modules'
  1. JBoss Modules
  2. MODULES-130

Private-Package and Export-Package in META-INF make classes unavailable

XMLWordPrintable

    • Hide

      Add the module org.apache.commons.beanutils

      <module xmlns="urn:jboss:module:1.1" name="org.apache.commons.beanutils">
          <resources>
              <resource-root path="commons-beanutils-1.8.3.jar"/>
              <!-- Insert resources here -->
          </resources>
      
          <dependencies>
              <module name="org.apache.commons.logging"/>
              <module name="org.apache.commons.collections"/>
          </dependencies>
      </module>
      

      and the module org.apache.commons.digester

      <module xmlns="urn:jboss:module:1.1" name="org.apache.commons.digester">
          <resources>
              <resource-root path="commons-digester-2.1.jar"/>
              <!-- Insert resources here -->
          </resources>
      
          <dependencies>
              <module name="javax.api" export="false"/>
              <module name="org.apache.commons.beanutils"/>
              <module name="org.apache.commons.logging"/>
          </dependencies>
      </module>
      

      Then, from any class from the digester module, the following expression

      this.getClass().getClassLoader().loadClass("org.apache.commons.beanutils.BeanMap")

      gives a ClassNotFoundException whereas it should find the class.

      Show
      Add the module org.apache.commons.beanutils <module xmlns= "urn:jboss:module:1.1" name= "org.apache.commons.beanutils" > <resources> <resource-root path= "commons-beanutils-1.8.3.jar" /> <!-- Insert resources here --> </resources> <dependencies> <module name= "org.apache.commons.logging" /> <module name= "org.apache.commons.collections" /> </dependencies> </module> and the module org.apache.commons.digester <module xmlns= "urn:jboss:module:1.1" name= "org.apache.commons.digester" > <resources> <resource-root path= "commons-digester-2.1.jar" /> <!-- Insert resources here --> </resources> <dependencies> <module name= "javax.api" export= " false " /> <module name= "org.apache.commons.beanutils" /> <module name= "org.apache.commons.logging" /> </dependencies> </module> Then, from any class from the digester module, the following expression this .getClass().getClassLoader().loadClass( "org.apache.commons.beanutils.BeanMap" ) gives a ClassNotFoundException whereas it should find the class.
    • Workaround Exists
    • Hide

      In the META-INF files remove either the Export-Package line or the Private-Package, or both of them.

      Show
      In the META-INF files remove either the Export-Package line or the Private-Package, or both of them.

      A module with a single jar as resource root which has in its META-INF the following lines:

      Export-Package: package1;version="1.8.3""
      Private-Package: package2;version="1.8.3"
      

      For any module which depends on this module, classes from package1 won't be resolved.

              dlloyd@redhat.com David Lloyd
              guinotphil Philippe Guinot (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: