3 Replies Latest reply on Aug 20, 2013 9:26 AM by ctomc

    Shared library loading within jboss as 7.x

    jkrmelj

      Hi,

       

      I have a question regarding shared library loading within jboss as 7.x.

       

      I have multiple war applications deployed within same instance of jboss as 7. They all use/have dependency on custom server module which includes a common jar library. Within this common jar library there are few singleton objects defined. The problem I have is that this singleton objects are shared among all applications. That's what I don't want. I would like to have these singleton objects to be singletons just inside single application. How can I achieve this?

       

      I know I can achieve this by packaging common jar library within single application war (and stop using module dependency). But this is not the option here, because I want to be able to update common library without repackaging application war.

       

      I assume this issue is related to jboss as 7 classloading mechanism where modules are loaded with separate module classloader.

      Is there any way to configure applications to load common module with application classloader? Or configure a module in some speciffic way?

       

      I use jboss AS 7.1.2

       

      Excuse me if similar question was already answered. Please point me to another forum thread in this case.

       

      Thank you.

        • 1. Re: Shared library loading within jboss as 7.x
          alesj

          Afaik, there is no such ootb mechanism.

          It's either a module or embedded.

           

          But you could easily add this programatically -- via custom subsystem.

          e.g. Seam2 support is done in such a way

          • 2. Re: Shared library loading within jboss as 7.x
            jkrmelj

            Hello,

             

            is there any clue how to do this?

             

            For now I managed to register a custom subsystem based on custom server module. How to set applications now to use resources of this subsystem?

             

            Thank you.

            • 3. Re: Shared library loading within jboss as 7.x
              ctomc

              You could split your common.jar in two jars

              that would be one way of doing it.

               

              other would be simply define two modules that use same common.jar and then use include / exclude paths for some packages where you have your singleton classes.

               

               

              in any case is see that it would be better to split your jar in two parts, one with singletons, other with everything else.

               

               

               

              --

              tomaz