使用JMX连接访问GridKernalMBean

时间:2014-11-20 21:16:21

标签: java jmx gridgain

我可以从jconsole访问Gridgain bean,但是当我尝试使用JMX以编程方式访问网格内的Gridgain bean时,我得到“javax.management.NotCompliantMBeanException”

以下是我正在使用的代码:

String jmxUrl = "service:jmx:rmi:///jndi/rmi://" + HOST+ ":" + PORT + "/jmxrmi";
JMXServiceURL url = new JMXServiceURL(jmxUrl);
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); 
ObjectName objectName = new ObjectName("org.gridgain:grid=gridname,group=Kernal,name=GridKernal");
org.gridgain.grid.GridKernalMBean mbean = JMX.newMXBeanProxy(mbsc, objectName,   org.gridgain.grid.GridKernalMBean.class);

网格外的豆子工作正常: -

String jmxUrl = "service:jmx:rmi:///jndi/rmi://" + HOST+ ":" + PORT + "/jmxrmi";
JMXServiceURL url = new JMXServiceURL(jmxUrl);
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); 
ObjectName objectName = new ObjectName("org.gridgain:group=Kernal,name=GridGain");
org.gridgain.grid.GridGainMBean mbean = JMX.newMXBeanProxy(mbsc, objectName, org.gridgain.grid.GridGainMBean.class);

我是否遗漏了gridgain配置文件中的所有配置?

1 个答案:

答案 0 :(得分:1)

这意味着您的目标mbeans不是MXBeans并且正在暴露非标准数据类型。尝试使用javax.management.MBeanServerInvocationHandler创建代理。它更自由一点,但请记住,那些非标准类型属性不会出现在您的客户端中,除非它们是可序列化的并且在您的客户端类路径中。