3 Replies Latest reply: May 17, 2013 11:18 AM by santo RSS

AS 7.1.0.Final: MBean and Class Loading

santo Newbie


I'm trying to migrate an application from JBoss AS5 to JBoss AS7.1 but I found a problem and I'd like to ask you if it's normal and if there's another way to achieve what I need. I have several MBeans whose code are contained in module X that are declared in a jboss-service.xml file in the SAR module Y, and these MBeans need some resource files packed in module Y (I usually use Thread.currentThread().getContextClassLoader().getResource() to access them). Now here's my problem: in JBoss 5, the context class loader of the thread executing start() was the class loader associated with module Y, while now in JBoss7 the class loader is instead associated with module X, so I can't locate the resources I need (module X doesn't depend from module Y). Is this the right behavoiur? Is there any way for me to access the resources in module Y?


  • 1. Re: AS 7.1.0.Final: MBean and Class Loading
    Bruno Santos Newbie

    I'm having the same issue!


    Did you find a solution for this?



  • 2. Re: AS 7.1.0.Final: MBean and Class Loading
    Gábor Trexler Newbie



    Anyone already has a solution for this?



  • 3. Re: AS 7.1.0.Final: MBean and Class Loading
    santo Newbie

    In the end I used a solution I wasn't satisfied with, but at least worked. I used different file names for the resource files I wanted to load and added in the MBean configuration the exact name of the resource to load for that MBean instance, this way the code was able to load the right resource. The problem with this approach is that you have to make sure that all the resource files used this way have different names, so use with a naming convention so that all resource files have a unique name.


    P.S. It's been quite a long time so I'm not 100% sure about this answer, but unfortunaly I have no more access to the code I was working with in that period so I hope this solution really works