Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14055

Re: Registering MBeans in a central MBeanServer

From Sebastian <sebastian@undisclosed.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Registering MBeans in a central MBeanServer
Date 2012-04-30 16:05 +0200
Organization albasani.net
Message-ID <jnm66f$4b3$1@news.albasani.net> (permalink)
References <jn8up9$122$1@news.albasani.net>

Show all headers | View raw


Am 25.04.2012 15:38, schrieb Sebastian:
> Hello there,
>
> I'd like to register MBeans that are local to several applications -
> each running in their own JVM - in a central MBeanServer. An operation
> invocation on that registered bean (e. g. using a jconsole connected to
> the central server) should result in a remote callback (probably via
> RMI) to the local bean, which would be registered in its platform
> MBeanServer.
>
> In other words, instead of creating a local bean on the central server,
> I'd like to create a remote proxy to my application-local bean and
> register that
[snip]

I ascribe the lack of response to my not actually having asked a 
question. Meanwhile, I have implemented something, which has a 
surprising behavior. I'll describe the code in some detail below (and 
ask a question about it, too).

Consider two JVMs, one "local" and one "central". The local JVM has an 
MBean server listening on port 7777 (defined by the system property 
com.sun.management.jmxremote.port=7777), the central one has port 6666.

   String localUrl = "service:jmx:rmi:///jndi/rmi://"
     + InetAddress.getLocalHost().getHostAddress() + ":7777"
     + "/jmxrmi";

   String remoteUrl = "service:jmx:rmi:///jndi/rmi://"
     + "centralServer:6666"
     + "/jmxrmi";

On the local side, I simply register an MBean in the platform MBS:

   StandardMBean mbean = new StandardMBean( this,
     ComponentController.class, false );
   MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
   mbs.registerMBean( mbean, oname() );

When I connect with JConsole to port 7777 and call one of the operations 
exposed by ComponentController, evertyhing works as expected.

Things start going wrong when I create a bean on the central server. 
That bean gets passed the service URL for my local MBS and the local 
bean's object name. Here's the code on the local side:

   JMXServiceURL centralUrl = new JMXServiceURL( remoteUrl );
   JMXConnector connector = JMXConnectorFactory.connect( centralUrl );
   MBeanServerConnection conn = connector.getMBeanServerConnection();
   conn.createMBean(
     "com.test.ComponentControllerCallback",
     oname(),
     new Object[] { localUrl, oname() },
     new String[] { "java.lang.String", "javax.management.ObjectName" } )

The methods in ComponentControllerCallback (which also implements 
ComponentController) are supposed to use that information to obtain the 
necessary connection to my local bean and call it back.

The very strange thing is that the simple presence of the above code to 
create an MBean on a different JVM wreaks havoc with my local MBS. That 
is, even if I connect again directly to the MBS on port 7777 (bypassing 
the central server), the methods that worked before will now throw 
ClassNotFoundExceptions for RMI-based classes. Deleting the above code 
snippet will restore correct behavior.

Unfortunately, the class loading behavior of my application is too 
complicated to reproduce or describe briefly. It is a composite 
application developed with the SCA implementation of Apache Tuscany.

But anyway: Does anyone have any idea what it is about JMX and the above 
code that could possibly throw the remote classloading mechanism into 
disarray?

I did try reversing the order of local bean registration and remote bean 
creation, but to no avail. Could it be the fact that both JVMs run on 
the same host? I'm stumped. Perhaps there is an entirely different and 
better way to implement my requirement?

-- Sebastian

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Registering MBeans in a central MBeanServer Sebastian <sebastian@undisclosed.invalid> - 2012-04-25 15:38 +0200
  Re: Registering MBeans in a central MBeanServer Sebastian <sebastian@undisclosed.invalid> - 2012-04-30 16:05 +0200
    Re: Registering MBeans in a central MBeanServer Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-01 10:37 -0300
  Re: Registering MBeans in a central MBeanServer ratornado@gmail.com - 2012-07-05 04:17 -0700

csiph-web