来自 JMX.newMBeanProxy() 的意外行为
Unexpected behavior from JMX.newMBeanProxy()
我为远程 JVM 获取了一个 ThreadMXBean 代理
ObjectName objName = ManagementFactory.getThreadMXBean().getObjectName() ;
ThreadMXBean proxy = JMX.newMBeanProxy(MBeanServerConnection, objName, ThreadMXBean.class);
但是,当我调用以下命令时,它说无法从 CompositeDataSupport
转换为 ThreadInfo
。
ThreadInfo tInfo = proxy. getThreadInfo(true, true);
代理不应该负责所有转换吗?此外,我在有效的 ThreadMXBean 上调用 getThreadInfo()
。
ThreadMXBean
is an MXBean. Your code has called JMX#newMBeanProxy
. The proxy returned by this method is not capable of handling the properties of MXBeans. Instead, use JMX#newMXBeanFactory
获取能够处理 MXBeans 属性的代理。
ThreadMXBean proxy = JMX.newMXBeanProxy(MBeanServerConnection, objName, ThreadMXBean.class);
我为远程 JVM 获取了一个 ThreadMXBean 代理
ObjectName objName = ManagementFactory.getThreadMXBean().getObjectName() ;
ThreadMXBean proxy = JMX.newMBeanProxy(MBeanServerConnection, objName, ThreadMXBean.class);
但是,当我调用以下命令时,它说无法从 CompositeDataSupport
转换为 ThreadInfo
。
ThreadInfo tInfo = proxy. getThreadInfo(true, true);
代理不应该负责所有转换吗?此外,我在有效的 ThreadMXBean 上调用 getThreadInfo()
。
ThreadMXBean
is an MXBean. Your code has called JMX#newMBeanProxy
. The proxy returned by this method is not capable of handling the properties of MXBeans. Instead, use JMX#newMXBeanFactory
获取能够处理 MXBeans 属性的代理。
ThreadMXBean proxy = JMX.newMXBeanProxy(MBeanServerConnection, objName, ThreadMXBean.class);