on 02-15-2007 7:42 PM
Is it possible to register an MBean remotely, and have it accessible via the Visual Administrator? (and shouldn't I see the bean using the monitoring service whether I extend BroadcastingStandardMBeanWrapper or not?)
I've been through 3 or 4 iterations now, but here's a snippet of what I'm looking at currently.
MBeanServerConnection mbsc = m.connect();
String pathInTheTree = "/Applications/Remote JMX";
/* Create the Hello World MBean */
Hello mbean = new Hello();
ObjectName cl = ObjectNameFactory.getNameForClassLoader("sap.com/myclassloader", null, null);
Properties p = new Properties();
p.setProperty("admin.path", "/Cluster/MyMBean");
p.setProperty("admin.displayName", "MyMBean");
BroadcastingStandardMBeanWrapper wrapper = new BroadcastingStandardMBeanWrapper(mbean, null, p);
ObjectName name = ObjectNameFactory.getNameForServerChildPerNode(ObjectName.quote(pathInTheTree), wrapper.getClass().getName(), null, null);
if (mbsc.isRegistered(name)) {
mbsc.unregisterMBean(name);
}
mbsc.createMBean(wrapper.getClass().getName(), name, cl);
Which yields the following stack trace:
Exception in thread "main" javax.management.ReflectionException
at com.sap.engine.services.jmx.MBeanServerConnectionImpl.invokeMbsInternal(MBeanServerConnectionImpl.java:523)
at com.sap.engine.services.jmx.MBeanServerConnectionImpl.createMBean(MBeanServerConnectionImpl.java:128)
at com.example.mbeans.Main.main(Main.java:57)
Caused by: java.lang.NoSuchMethodException: com.sap.engine.services.basicadmin.mbean.BroadcastingStandardMBeanWrapper.<init>()
at java.lang.Class.getConstructor0(Class.java:1937)
at java.lang.Class.getConstructor(Class.java:1027)
at com.sap.engine.services.jmx.CompletionInterceptor.instantiate(CompletionInterceptor.java:632)
at com.sap.engine.services.jmx.CompletionInterceptor.createMBean(CompletionInterceptor.java:272)
at com.sap.engine.services.jmx.CompletionInterceptor.createMBean(CompletionInterceptor.java:250)
at com.sap.pj.jmx.server.interceptor.BasicMBeanServerInterceptor.createMBean(BasicMBeanServerInterceptor.java:94)
at com.sap.engine.services.jmx.RedirectInterceptor.createMBean(RedirectInterceptor.java:157)
at com.sap.pj.jmx.server.interceptor.MBeanServerInterceptorChain.createMBean(MBeanServerInterceptorChain.java:202)
at com.sap.engine.services.jmx.MBeanServerSecurityWrapper.createMBean(MBeanServerSecurityWrapper.java:210)
at com.sap.engine.services.jmx.MBeanServerInvoker.invokeMbs(MBeanServerInvoker.java:102)
at com.sap.engine.services.jmx.ClusterInterceptor.invokeMbs(ClusterInterceptor.java:212)
at com.sap.engine.services.jmx.ClusterInterceptor.createMBean(ClusterInterceptor.java:391)
at com.sap.engine.services.jmx.MBeanServerInterceptorInvoker.invokeMbs(MBeanServerInterceptorInvoker.java:75)
at com.sap.engine.services.jmx.connector.p4.P4ConnectorServerImpl.invokeMbs(P4ConnectorServerImpl.java:61)
at com.sap.engine.services.jmx.connector.p4.P4ConnectorServerImplp4_Skel.dispatch(P4ConnectorServerImplp4_Skel.java:64)
at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320)
at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
This seems to be due to the absence of a no-arg contructor (which is not required by the spec, IIUC), so I hacked around that by wrapping the wrapper (aack) and delegating method invocations appropriately... This runs normally, but I still don't see my MBeans in the visual admin console.
Thoughts, anyone?
TIA,
Bill
Figured it out myself. Was using the wrong MBeanServerConnection.createMBean method - the one that tries to instantiate the mbean with a no-arg constructor. <:-|
Should have been:
Hello mbean = new Hello();
...
Object[] params = new Object[] { mbean, HelloMBean.class, p };
String[] sig = new String[] { "java.lang.Object", "java.lang.Class", "java.util.Properties" };
mbsc.createMBean(wrapperClass, objectName, classloaderName, params, sig);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.