2 Replies Latest reply on Jan 15, 2009 3:24 AM by jguyard

    Isolation with shared libraries instances?

      Hi all,

      this is my first time posting here.

      First of all, I've read almost everything here: http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/beta422/html-single/index.html#Inside_the_JBoss_Class_Loading_Architecture-The_core_JBoss_class_loading_components


      I'm working with JBOSS 4.2.3 and my current mission is to deploy the same ear twice in the same jboss server instance.
      I had isolation problems (ClassCastException,...), so I decided to start with something very easy and write this TestCase:

      I have a ear containing a servlet. This servlet, when requested, prints the fully qualified name of a singleton and his memory address. So here is what I have (TestCase2.ear is a duplication of TestCase1.ear with a different context-root for requesting them seperatly):

      server
      |
      --- deploy
      | |
      | --- ear-deployer.xml (isolated parameter setted to true)
      | |
      | --- TestCase1.ear
      | | |
      | | --- TestCase1.war
      | | |
      | | --- WEB-INF
      | | |
      | | --- classes
      | | | |
      | | | --- myServlet.class
      | | |
      | | --- lib
      | | |
      | | --- mySingleton.jar
      | --- TestCase2.ear
      | | |
      | | --- TestCase2.war
      | | |
      | | --- WEB-INF
      | | |
      | | --- classes
      | | | |
      | | | --- myServlet.class
      | | |
      | | --- lib
      | | |
      | | --- mySingleton.jar


      RESULT: The servlets print the same fully qualifiedName but different memory addresses. Until now everything is how I expected.

      ______________________________________________________

      Then this is the second test:


      server
      |
      --- deploy
      | |
      | --- ear-deployer.xml (isolated parameter setted to true)
      | |
      | --- TestCase1.ear
      | | |
      | | --- TestCase1.war
      | | |
      | | --- WEB-INF
      | | |
      | | --- classes
      | | |
      | | --- myServlet.class
      | |
      | --- TestCase2.ear
      | | |
      | | --- TestCase2.war
      | | |
      | | --- WEB-INF
      | | |
      | | --- classes
      | | |
      | | --- myServlet.class
      | |
      --- lib
      | |
      | --- mySingleton.jar


      RESULT: The servlets print the same fully qualifiedName, the same classloader (UnifiedClassLoader3) AND the same memory addresses. This is very troublesome because this is not what I was waiting.

      I fully understand why they are loaded by the same UCL. For me, every jars in the lib directory of the server are shared libraries. But I don't understand why instances are shared between ears.

      Is this some kind of bug? Or is there another "shared lib directory" to do what I try to do?



      Regards,

      J. Guyard

        • 1. Re: Isolation with shared libraries instances?
          peterj

          By placing mySingleton.jar into the lib directory, you have essentially stated that you want it to be shared about all of your applications. Thus isolation pertains only to JARs local to the EAR.

          By default, classes are shared among apps (except classes in WARs). Thus if you did not set isolation, and had mySingleton.jar in TestCase1.ear, then the classes in TestCase2.ear would be able to see the classes in mySingleton.jar.

          • 2. Re: Isolation with shared libraries instances?

            Thanks for your quick reply Peter.

            I thought I was a bug in JBoss, but I guess I have no other choice but embedding all the shared libraries in my different ears if I deploy them in the same jboss instance.

            J. Guyard