File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes JMX: registerMBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "JMX: registerMBean" Watch "JMX: registerMBean" New topic
Author

JMX: registerMBean

Ann Carpentier
Greenhorn

Joined: Sep 22, 2004
Posts: 5
Hi,

I'm having troubles with JMX. In the code below, you see how I register an MBean.
The problem is, that from everywhere in my application, I call this particular code, and I give as return-value my oltbMBean. I have the feeling, that I'm working with different MBeans, each time I call the code below. The result is, that my values have the initial value...



I suppose you only have to register, a specific MBean, just one time. Is it possible to find the 'registered' MBean?
I know I'm missing something, but I don't know what...


Can anyone help me? It's very urgent...

Thanks in advance,
Ann Carpentier
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18101
    
  39

The problem is, that from everywhere in my application, I call this particular code, and I give as return-value my oltbMBean. I have the feeling, that I'm working with different MBeans, each time I call the code below. The result is, that my values have the initial value...


Yes, this code will create a new instance and register it with the MBean Server. So, if you call the code again, you will get a new MBean registered.

I suppose you only have to register, a specific MBean, just one time. Is it possible to find the 'registered' MBean?
I know I'm missing something, but I don't know what...


More commonly, the registerMBean() method is not available -- since most of the time, application work through a connector, instead of the MBean server directly. The reason that you can is because you are running in the same JVM as the MBean server. This trick will not work if you are connecting with JNDI via a different JVM.

Anyway, since you are in the same JVM, just register it once, and store the MBean somewhere in a globally accessable reference. The next time you need the MBean, just return the previously instantiated reference.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Alan Hermin
Ranch Hand

Joined: Feb 16, 2006
Posts: 290
Can someone tell me what is the Java Managment Extension(JMX)?and wh its use?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMX: registerMBean
 
Similar Threads
Servlet access to MBean in JBoss
Accessing application-level default work manager
How to reference a JMX MBean ?
How to get MBeanServer from Servlet?
Suspending/Pausing a MDB's Consumption Programmatically