4 Replies Latest reply on Jul 13, 2011 12:57 PM by normandesjr

    Access other classloader JBoss AS 5.1.0.GA

    normandesjr

      Hi,

       

         I have two ear files. Each one with isolated classloader through file jboss-web.xml (<loader-repository>myFirstApp.package:loader=myFirstApp.ear</loader-repository>).

       

         At the first ear I have a MDB. At the other ear I have just a simple jar inside lib directory.

       

         I would like that the first ear (inside MDB) creates an object from the second ear through reflection API and call a method (If you think that is easier implement through EJB3, I can change it).

       

         But one important requirement, I can't change my MDB when I add a second jar or ejb. Could you understand me?

       

         I am using JBoss AS 5.1.0.GA

       

         Thanks a lot for your help.

       

      Normandes Junior.

        • 1. Re: Access other classloader JBoss AS 5.1.0.GA
          alesj

             I have two ear files. Each one with isolated classloader through file jboss-web.xml (<loader-repository>myFirstApp.package:loader=myFirstApp.ear</loader-repository>).

           

             At the first ear I have a MDB. At the other ear I have just a simple jar inside lib directory.

           

             I would like that the first ear (inside MDB) creates an object from the second ear through reflection API and call a method (If you think that is easier implement through EJB3, I can change it).

           

             But one important requirement, I can't change my MDB when I add a second jar or ejb. Could you understand me?

          Unfortunately no.

           

          Let me make a wild guess.

          It looks like you already have both .ears using the same domain -- myFirstApp.package:loader=myFirstApp.ear.

          Hence it should be possible to cross ref these classes, which confuses me even more ...

          • 2. Re: Access other classloader JBoss AS 5.1.0.GA
            normandesjr

            Sorry, I will try explain better.

             

            Both .ears are using different domains: myFirstApp.package:loader=myFirstApp.ear and mySecondApp.package:loader=mySecondApp.ear.

             

            My desire is that the my team develop just the secondApp, thirdApp and so on. The FirstApp will be a kind of framework that receive a jmsMessage and decide wich app execute. And each app has its own domain.

             

            I would like access classes of other domain. Its better now or would you like more information?

             

            Thanks for your help.

            • 3. Re: Access other classloader JBoss AS 5.1.0.GA
              alesj

              With JBossAS5/6 you can create a hierarchy of CL domains:

              * http://java.dzone.com/articles/jboss-microcontainer-classloading

               

              Perhaps having FirstApp as the parent to all others; SndApp, ThirdApp, ... could/would work for you.

              e.g. FirstApp would hold the common classes, to exchange the data

               

              But JMS is already a nice way to decouple apps, which you might just need to tweak a bit.

              e.g. each app has it own queueu, where FirstApp just properly pushes it down the right queue

              • 4. Re: Access other classloader JBoss AS 5.1.0.GA
                normandesjr

                Thanks Ales,

                 

                   I am going to read the article now and see if it can help me. I have to understand better about the classloading.

                 

                   Actually, nowdays I am using JMS to decouple apps, but I would like to create a framework to facilitate de development for my team. I don't want that they make "ifs" or use selectors, I would like a interface between JMS and the applications.

                 

                   Thanks for your help. If I get any progress I update here.

                 

                    Regards,

                 

                Normandes Junior.