Dependency is not down to the level of class loading. If you read the service mbean behavior in chapter 2 of the server guide it will be clear that the service lifecycle notion applies well have the service is created in the jvm.
The jboss5 microcontainer will support class loader level dependencies.
Thanks for the quick reply, but I'm not quite sure I understand your answer. Perhaps this isn't the proper board for this question, because this is really a classloading question; I just happened to run into the problem when deploying an MBean.
My goal is to have only one copy of every class anywhere in the server because we are using the Unified ClassLoader with class sharing among all applications. Having 2 copies of a class has caused problems in the past. For example,
Class A in package com.example has protected method callMe().
Class B, also in package com.example tries to call A's callMe().
The WEB-INF/lib directory of a war file contains a jar that contains both A and B, and a utility jar contained in a separate ear also contain A and B.
Class A and class B happen to be loaded by different classloaders (one for the ear, one for the war).
Result is an IllegalAccessError.
Our solution is to use the following rules for deployment:
- Only one deployment unit should contain any class.
- All classes in a particular package should always be included in the same deployment unit.
Now, I have an MBean that depends on an EJB. The EJB's local interface is already being deployed in a separate deployment unit. Since the SAR that contains the MBean will not always be deployed with the application, I don't want to include the local interface ONLY in the SAR.
Are you saying it's impossible to make the MBean depend on the EJB without including the classes in the SAR? What is the recommended approach for deployment in this situation, given that we are sharing classes across applications? Putting the classes in the lib directory for my configuration is not an option, since I would like hoy deployment to work. Thanks,
One solution would be to package all the shared classes in a .jar, and use e.g. the PrefixDeploymentSorter in the DeploymentScanner to deploy this .jar before the .sar & ejbs