How can I register to the server an MBean created on the client?
The answer to this is simple: you can't (or you shouldn't
The registerMBean(..) method has been erroneously exposed by the
JBoss RMIAdaptor for a long time now. If you are using the RMIAdaptor
you should really change you code to use the JMXv1.2 compliant interface,
the
MBeanServerConnection
.
You'll notice that this interface does not expose a registerMBean() method.
This is in accordance to the JMX specification which clearly states that
registerMBean() is really meant for registering MBeans local to the MBeanServer
(JMXv1.2 spec, page 134).
MBeans are not designed to be serializable across JVMs and even if you manage
to stream an MBean from a client to the server, this would mean that changes
to the client local copy wouldn't be reflected on the MBean exposed on the server.
In a few words, this is against the design principles of JMX.
The correct way to do it, is to use the
MBeanServerConnection
inteface
and one of the createMBean(..) methods to tell the server to instantiate
and register an MBean on the server side. You can then proceed by setting
attributes and calling operations on that MBean through the remote
MBeanServer, always referencing the MBean by its ObjectName, because at
that point, only the MBeanServer has a direct reference to it.
Related:
Referenced by:
Comments