从JBoss EAP 6.4连接到JMX MBean

时间:2015-06-29 11:22:55

标签: jmx jboss-eap-6 mbeans

我正在尝试使用JBoss EAp 6.4中的java代码连接到JMX,但我收到一条错误消息:

java.lang.IllegalArgumentException: MBeanServer argument must be MBean server where this server is registered, or an MBeanServerForwarder leading to that server

我的standalone.xml文件有:

        <subsystem xmlns="urn:jboss:domain:jmx:1.3">
            <expose-resolved-model/>
            <expose-expression-model/>
            <remoting-connector/>
        </subsystem>

使用的端口是:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:7204}"/>
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:7203}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:7205}"/>
        <socket-binding name="http" port="7201"/>
        <socket-binding name="https" port="7202"/>
        <socket-binding name="ajp" port="7206"/>
        <socket-binding name="remoting" port="7207"/>
        <socket-binding name="txn-recovery-environment" port="7208"/>
        <socket-binding name="txn-status-manager" port="7209"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>

我正在使用的Java代码是:

_mbeanServer = ManagementFactory.getPlatformMBeanServer();
String domain = "HtmlAdaptor";
HtmlAdaptorServer adapter = new HtmlAdaptorServer();
String domain = "com.mn";
Hashtable<String,String> params = new Hashtable<String, String>();
params.put("name", "JMXHtmlAdaptor");
params.put("port", String.valueOf(_jmxHttpPort));
ObjectName adapterName = new ObjectName(domain, params);
adapter.setPort(_jmxHttpPort);
server.registerMBean(adapter, adapterName);
adapter.setMBeanServer(_mbeanServer);

// _jmxHttpPort = 10099
// ManagementFactory.getPlatformMBeanServer(); returns object of type org.jboss.as.jmx.PluggableMBeanServerImpl
// adapter.getMBeanServer() returns com.sun.jmx.mbeanserver.JmxMBeanServer
// server returns object of type org.jboss.as.jmx.PluggableMBeanServerImpl

我认为创建的适配器类型错误。

知道如何解决此问题吗?

0 个答案:

没有答案