0 Replies Latest reply on Apr 15, 2013 8:03 AM by andrei.serea

    JBoss 7.x SAR archive class loading issue

    andrei.serea

      I am trying to build a sar archive that contains an MXBean and deploy it in JBoss 7.

      Until recently I had a problem referencing classes from other libraries in my MXBean class because JBoss wouldn't load those libraries no matter where in the SAR archive I'd put them.

      I found out that one can configure the classpath of a SAR through the jboss-deployment-structure.xml file placed in META-INF. My version of this file looks like this:

      <jboss-deployment-structure> <deployment> <resources> <resource-root path="management.api.jar" /> </resources> </deployment>

       

      Now the classes from the "management.api.jar" are loaded.

      The problem I am now facing is the following: If the interface of the MXBean is stored in the management.api.jar and the class implementing it is directly in the SAR archive, then, when JBoss reads the jboss-service.xml and tries to create the mxbean it yields a ClassNotFoundException pointing to the interface (that is in the management.api.jar). Hence, although classes from the external jar are loaded ok (i tested this by actually invoking a method that referenced a class from the jar and it worked), it seems that when JBoss registers the bean, it doesn't go through the whole classpath as defined in the jboss-deployment-structure.xml.

      I am currently stuck and I suspect this to be a bug in the way JBoss handles the class loading.

       

      I worked around this issue by adding the "management.api.jar" library as a module in the jboss modules dir, but this is a workaround and I'm sure the variant presented should work, somehow.

       

      My question is...is this a bug or is there some other (hidden) way to configure it to work as intended?

       

      Andrei.