远程JMX调用的NoRouteToHostException / NoSuchHostException

时间:2012-05-31 11:16:12

标签: rmi jmx jboss6.x centos5

我无法在Centos 5.6服务器上对JBoss 6进行远程JMX调用。我以前能够在Debian服务器上运行相同的应用程序时执行此操作。

./twiddle.sh --server=service:jmx:rmi:///jndi/rmi://SERVER:1090/jmxconnector invoke foo:service=bar baz

Caused by: java.net.NoRouteToHostException: No route to host
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at java.net.Socket.<init>(Socket.java:375)
    at java.net.Socket.<init>(Socket.java:189)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)

如果我在SERVER上本地运行它,则相同的调用成功。我用iptables打开了端口1090,我可以通过telnet连接到SERVER:1090。 hostname -i返回正确的IP地址。

我也试过用-Djava.rmi.server.hostname=localhost启动JBoss。如果我这样做,那么我会得到一个不同的例外:

Caused by: java.rmi.NoSuchObjectException: no such object in table
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
    at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
    at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2327)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:279)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
    at org.jboss.console.twiddle.Twiddle.createMBeanServerConnection(Twiddle.java:322)
    at org.jboss.console.twiddle.Twiddle.connect(Twiddle.java:331)
    at org.jboss.console.twiddle.Twiddle.access$400(Twiddle.java:60)
    at org.jboss.console.twiddle.Twiddle$1.getServer(Twiddle.java:217)

2 个答案:

答案 0 :(得分:5)

事实证明,除了端口1090之外,JMX / RMI还使用动态分配的端口,该端口被防火墙阻止。所以,如果合适的话,完全禁用防火墙,否则这似乎是另一种选择(我还没试过):

http://olegz.wordpress.com/2009/03/23/jmx-connectivity-through-the-firewall/

答案 1 :(得分:1)

我做的是:

更新文件activemq.xml并指定rmiServerPort。

<managementContext createConnector="true" connectorPort="SOME_PORT" rmiServerPort="SOME_OTHER" jmxDomainName="org.apache.activemq"/>

通过更新你的iptables条目来允许两个端口,重新启动activemq它应该可以工作。