2 Replies Latest reply on Apr 9, 2008 7:18 AM by jaikiran

    some question on the classloader

    niefeng

      We have migrated from JBOSS4.0.5 GA to JBOSS4.2.2, and we encounter the class loader issue.

      We have packaged the java mail.jar in our application archive (due to our application archive can be deployed in different AS, so we include that instead of depending the existing mail.jar in JBOSS\server\default\lib), and we discovered the NoClassDefFoundError.

      java.lang.NoClassDefFoundError: javax/mail/Address
       at javax.mail.Session.getTransport(Session.java:681)
       at javax.mail.Transport.send0(Transport.java:148)
       at javax.mail.Transport.send(Transport.java:80)


      We didn't have such an issue in JBOSS405. And I have read the following wiki regard the class loader

      http://wiki.jboss.org/wiki/JBossClassLoadingUseCases

      Our case is fall within use case 4. Below is the jboss-app.xml defined for the application archive

      <jboss-app>
       <loader-repository>
       com.test:loader=test.ear
       <loader-repository-config>
       java2ParentDelegation=true
       </loader-repository-config>
       </loader-repository>
      </jboss-app>


      Case 4. The Utility.class is present both in the application's archive AND server/default/lib. The deployment is scoped, but java2ParentDelegation is turned on.


      The snippet from the use case 4
      What happens if the parent delegation is true and a classloader already loaded the class in the parent repository's class cache? Answer: My scoped application will use the already loaded class from the parent repository's class cache


      Based on that, the JBOSS AS will not load the javax/mail/Address within our application archive, it will load from the server/default/lib/mail.jar. However, the javax/mail/Address can't be found in the class path, and throwing the NoClassDefError.

      Could I know why JBOSS AS can't locate the javax/mail/Address under server/default/lib although my configuration is fall within the case 4?

        • 1. Re: some question on the classloader
          niefeng

          Hi all,

          Did I miss out any info that i didn't provide to let you better undertand my problem?

          Thanks

          • 2. Re: some question on the classloader
            jaikiran

             

            "niefeng" wrote:

            We have packaged the java mail.jar in our application archive (due to our application archive can be deployed in different AS, so we include that instead of depending the existing mail.jar in JBOSS\server\default\lib)

            <jboss-app>
             <loader-repository>
             com.test:loader=test.ear
             <loader-repository-config>
             java2ParentDelegation=true
             </loader-repository-config>
             </loader-repository>
            </jboss-app>




            So, the java2ParentDelegation should be set to "false", isn't it?