This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JMX in JBoss

 
Ayan Dutta
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21001
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Henry Wong
author
Marshal
Pie
Posts: 21001
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, forgot to disable smilies in the last post. Here is the JNDI code again...

 
Ayan Dutta
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic