7

我在 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. 如果我这样做,那么我会得到一个不同的异常:

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)
4

2 回答 2

5

事实证明,除了端口 1090,JMX/RMI 还使用动态分配的端口,该端口被防火墙阻止。因此,如果合适,请完全禁用防火墙,否则这似乎是一种替代方案(我还没有尝试过):

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

于 2012-06-08T14:06:20.087 回答
1

我所做的是这样的:

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

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

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

于 2013-10-10T21:49:51.430 回答