Platform: Linux cameron 2.6.38-11-generic-pae #48-Ubuntu SMP Fri Jul 29 20:51:21 UTC 2011 i686 i686 i386 GNU/Linux
JBoss AS: 17:31:00,709 INFO [org.jboss.modules] JBoss Modules version 1.0.1.GA
17:31:01,508 INFO [org.jboss.msc] JBoss MSC version 1.0.0.GA
17:31:01,614 INFO [org.jboss.as] JBoss AS 7.0.1.Final "Zap" starting
I have not messed with the class-loader configuration in the JBoss installation.
I'm trying to install an MBean. My code currently uses method call
|mbeanServer.createMBean( className, bname );|
where className is the name of the MBean class and bname is the ObjectName for the bean. Note that the class name is the name of the implementation, not its JMX interface. The createMBean method is getting called from a @PostConstruct method in a stateless session bean; the construction of the stateless session bean is triggered by a method call in the init method of a servlet being loaded at startup time (load-on-startup is 1), which contains an @EJB injection of the stateless session bean. The mbeanServer is obtained via
Before I call the createMBean method, I verify that the bean implementation class is visible to the stateless session bean via
Class.forName( className )
in the session bean. This method succeeds. The code is being deployed from an .ear file with the following structure:
+ loaderbean.jar (an ejb jar file)
+ loader.war (contains the servlet)
+ bean.jar (containing the referenced class and its JMX interface)
What I see, at the point of the createMBean call, is a class-not-found exception:
17:31:39,915 ERROR [stderr] (MSC service thread 1-2) Caused by: java.lang.ClassNotFoundException: com... (class name passed to createMBean)
17:31:39,916 ERROR [stderr] (MSC service thread 1-2) at com.sun.jmx.mbeanserver.ClassLoaderRepositorySupport.loadClass(ClassLoaderRepositorySupport.java:228)
17:31:39,916 ERROR [stderr] (MSC service thread 1-2) at com.sun.jmx.mbeanserver.ClassLoaderRepositorySupport.loadClass(ClassLoaderRepositorySupport.java:141)
17:31:39,916 ERROR [stderr] (MSC service thread 1-2) at com.sun.jmx.mbeanserver.MBeanInstantiator.findClassWithDefaultLoaderRepository(MBeanInstantiator.java:93)
17:31:39,916 ERROR [stderr] (MSC service thread 1-2) ... 71 more
That is, it appears to me that although the stateless session bean in the loaderbean.jar file can see the bean implementation in the bean.jar file, the actual MBean server cannot see the implementation class. I understand that this is probably some sort of class-loader issue, but I can't figure out what to do nest. That is, my basic question is:
How can I instantiate a new JMX bean instance in the JBoss MBean server, given the .ear file structure above?
NOTE: I found some references to annotations @Service and @Management, which appear to have been the JMX deployment approach in earlier versions of JBoss. As far as I can tell, though, these annotations aren't present in any of the AS 7 modules, which makes me think that they are no longer supported. I can deal with a JBoss-specific annotation by deploying a special JBoss-only jar file in the .ear, a deployment which could be removed if I change to a non-JBoss container. Even without annotations, if the fix involves making the JMX beans visible as deployed objects, rather than being buried down in the lib directory, I can deal with that as well... but is that the right fix?