This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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.
Oops, forgot to disable smilies in the last post. Here is the JNDI code again...
Joined: Oct 16, 2005
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