【发布时间】:2012-11-07 22:05:34
【问题描述】:
这个用于 RMI JMX 连接的 Java 代码有什么问题?我显然没有尝试连接到本地主机,但错误暗示我是。在远程服务器上,我在端口 1099 上启用了 JMX 选项(无身份验证)。
这是我的 groovy 脚本:
import javax.management.remote.*;
JMXServiceURL u =
new JMXServiceURL("service:jmx:rmi://10.222.244.185:9999/jndi/rmi://10.222.244.185:1099/jmxrmi");
JMXConnector c = JMXConnectorFactory.connect(u);
这是我得到的错误:
C:\Temp>groovy jmx.gv
Caught: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Conn
ection refused to host: 10.222.244.185; nested exception is:
java.net.ConnectException: Connection refused: connect]
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection r
efused to host: 10.222.244.185; nested exception is:
java.net.ConnectException: Connection refused: connect]
at jmx.run(jmx.gv:5)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 10.222.244.185; nested except
ion is:
java.net.ConnectException: Connection refused: connect]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
... 1 more
Caused by: java.rmi.ConnectException: Connection refused to host: 10.222.244.185; nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
... 2 more
Caused by: java.net.ConnectException: Connection refused: connect
... 3 more
【问题讨论】:
-
对不起,伙计们。我刚刚发现远程 JVM 在 OpenJDK 上运行,而我使用的 VisualVM 在 Oracle Hotspot 上。一定是这个问题?
-
不应该。更有可能它根本没有运行。
-
ping 和 telnet 是否对 host:ports 有效? (只是为了排除网络问题)