4 Replies Latest reply on Oct 21, 2010 4:49 PM by sannsims

    In what order are classes loaded?

    sannsims Newbie

      Hello,

      I'm a newbie to JBoss 5.  According to the "JBoss AS 5 Development" book, it states the following about the common folder:

       

           This directory hosts the lib folder, which is the new repository for the common libraries used by "all" application server configurations.

       

      When I start my web application, it cannot find the my classes in the /common/lib directory.  Are the classes in the /common/lib directory loaded after the classes in my web application (default directory)?  If so, how I can ensure my jar file in the /common/lib directory is loaded first?  My web application has a dependency on the classes in the /common/lib directory?

       

      Thanks in advance for your help!

        • 1. Re: In what order are classes loaded?
          Ales Justin Master

          The common/lib/ is loaded before your app, so you should see them.

          Perhaps you have some parent-child issue, as war's use child-first class lookup notion?

          • 2. Re: In what order are classes loaded?
            sannsims Newbie

            Hi Ales,

            Thanks for your quick reply!  Is there a way I can debug this issue; determine if the war is being loaded in the same class loader?  The classes should only exist in the common/lib directory.

             

            Thanks in advance for your help!

            • 3. Re: In what order are classes loaded?
              Fabio Schmitz Tani Newbie

              sannsims,

               

              Normally it's best not to add your dependencies on the common/lib, ideally you would leave the common/lib with the stock jars, and add you custom jars in your <server_name>/lib folder or more specific jars in your WEB-INF/lib (for War applications).

               

              JBoss loads the jars from common/lib, then the jars in <server_name>/lib and then the ones in the deploy folder, you can change the behavior using jboss-web.xml (or jboss-app.xml in ear) specific configurations. These configurations are normally only necessary if you want to bundle previous or conflicting jars with your application, for example an older or newer version of hibernate.

               

              It's possible in your case that you might have added some other libs to the classpath that are conflicting with current libs in other levels, if you could post a stack trace, it could be easier to track exactly what's happening.

              • 4. Re: In what order are classes loaded?
                sannsims Newbie

                Thanks fstani for your reply.  I needed to put my jar file in the common/lib directory so that it would be visible to other applications.  For example, I have a web application in the default directory and another one in the web directory; both will need visibility to the jar file in common/lib.  It seems I have this issue resolved though, I was missing some dependencies required by my jar file.