File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes JMX in JBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JMX in JBoss" Watch "JMX in JBoss" New topic
Author

JMX in JBoss

Ayan Dutta
Ranch Hand

Joined: Oct 16, 2005
Posts: 94
Can anybody provide me any sample code using MX4J api to connect to any MBean residing in JBoss 3.2.5 ? I am not getting any help on JBoss specific implementation.
Regards,
Ayan Dutta
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18702
    
  40

Originally posted by Ayan Dutta:
Can anybody provide me any sample code using MX4J api to connect to any MBean residing in JBoss 3.2.5 ? I am not getting any help on JBoss specific implementation.
Regards,
Ayan Dutta


MX4J is just an implementation of the JMX API. So once you get access to an mbean server (or connector), then you just use the standard JMX calls. As for how to get the connector there are a few options in JBoss. The easiest is probably through JNDI.

Now... both of these APIs are not so simple that you can learn it from "any sample code", but if you want to try...

Here is a sample on how to get the connector using JNDI:



Once you have the connector, here is a sample on how to get a list of all the instances (mbeans) in the system.



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18702
    
  40

Oops, forgot to disable smilies in the last post. Here is the JNDI code again...

Ayan Dutta
Ranch Hand

Joined: Oct 16, 2005
Posts: 94
I am getting the following exception at the line :
server = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");

The exception is

javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.jmx.adaptor.rmi.RMIAdaptor (no security manager: RMI class loader disabled)]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:654)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:509)
at javax.naming.InitialContext.lookup(Unknown Source)
at util.Connect2JBossMQ.fromJavaRanch(Connect2JBossMQ.java:99)
at util.Connect2JBossMQ.main(Connect2JBossMQ.java:16)
Caused by: java.lang.ClassNotFoundException: org.jboss.jmx.adaptor.rmi.RMIAdaptor (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.rmi.MarshalledObject.get(Unknown Source)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:30)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:552)
... 4 more


Do I need to configure anything in JBoss ?
Regards,
Ayan Dutta
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMX in JBoss