QuickTip: Programmatic MBean access under JBoss
I have been struggeling a bit with the programmatic access of MBeans under JBoss. This is my current conclusion.With JBoss 5 there are two methods for accessing MBeans:
- By JNDI-lookup of the RMIAdaptor. With this method you need the JBoss client libraries (the jars in your
$JBOSS_HOME/client
) on the classpath since the RMIAdaptor is a type that is provided by JBoss. - By pure JMX. You don't need the JBoss client libraries your class path here.
The following snipped shows both methods:
With JBoss 7 the way to access MBeans changed quite a bit: The tricky thing here is, that you need the JBoss client libraries (the jars in
$JBOSS_HOME/bin/client
) on your classpath even though you don't explicitly import types provided by JBoss. If the client libraries are missing, you get the following exception:
java.net.MalformedURLException: Unsupported protocol: remoting-jmx
As far as I could figure, this is the only way to access MBeans under JBoss 7.