Does MBean subclassing work in JBossMX?
coddingm Nov 2, 2002 2:59 PMIn comparing JBossMX w/ Sun's reference implementation, I've noticed at least once thing I thought was strange. JBossMX doesn't seem to allow me to extend an existing MBean interface.
I have two interfaces:
interface SuperMBean
public void method1()
interface SubMBean extends SuperMBean
public void method2()
and two classes:
class Super implements SuperMBean
public void method1()
class Sub extends Super implements SubMBean
public void method2()
I bind an instance of Sub like so:
ObjectInstance oi=server.createMBean("Sub",objectName)
then I invoke the second method:
server.invoke(objectName,"method2",new Object[]{}, new String[]{})
JBoss 3.0.3 reports:
ReflectionException: null
Cause: java.lang.NoSuchMethodException: Unable to locate method for: method2()
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:288)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl.invoke(RMIAdaptorImpl.java:283)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
at java.lang.reflect.Method.invoke(Method.java:327)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:264)
at sun.rmi.transport.Transport$1.run(Transport.java:151)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:147)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:463)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.lang.Thread.run(Thread.java:539)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:250)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:226)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:136)
at org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl_Stub.invoke(Unknown Source)
at org.jboss.jmx.connector.rmi.RMIConnectorImpl.invoke(RMIConnectorImpl.java:459)
at SubclassTester.main(SubclassTest.java:35)
However, this works fine with Sun's RI. And in the book "Jmx: Managing J2ee Applications with Java Management Extensions" this type of subclassing is used as an example.
Has anyone else seen this problem?