2 Replies Latest reply on Apr 7, 2005 9:56 AM by treespace

    jboss classloading question

    jbosss Newbie

      We are using JBoss 3.2.1

      I have a few questions about the class loading architecture.
      As I understand it, whenever a class is needed, the UnifiedClassLoader3 tries to get it from the ClassLoaderRepository cache. If it does not find it there, it tries to see if it can itself load the class. If that does not happen, it get a list of all the UCLS that are capable of providing the class based on the repository package name to UCL map. All these UCLs are queried for the requested class in order. If a UCL is found that can load the class it is returned, else a ClassNotFoundException in thrown.

      My questions:

      1. When are the UCLs added to the ClassLoaderRepository? Suppose I want to access a page called MyPage.jsp, then the loader will need to load the MyPage_jsp.class, right? So the first time it tries to load it, how does it work? It will obviously not find it in the repository cache since, this is the first time the page is accessed. Also currently there are no UCLs mapped to this in the repository. So how will it load it?

      2. Is a class unloaded anytime? I know that a UCL can be unregistered from the repository. When does this happen?


        • 1. Re: jboss classloading question
          jbosss Newbie

          One more question :
          1. Why do we have 3 versions of class loaders : UnifiedClassLoader, UnifiedClassLoader2 and UnifiedClassLoader3 ? Similarly for UnifiedLoaderRepository, again why 3 versions?

          • 2. Re: jboss classloading question
            treespace Novice

            Class loaders are nested to provide isolation. WARs use war-local resources, EARs use ear-local, ditto for SARs and so on. The configuration is next followed by jars or classes in the server.

            WAR files have the added requirement of an option that stipulates that no classes outside of system classes will be used. It's a security thing.

            The best solution is to use EARs to aggregate EJBs and WEB resources. You can also get away with a "java" modules in JBoss for loose jars specified in your application.xml, however, you should use your MANIFEST.MF to specify the dependencies between loose jars and your EARs 'n WARs. I create one manifiest for every jar and specify the dependencies (one level deep) in each. This eliminates duplicate jars and classes entirely, much cleaner.