java - 如何将 JConsole 连接到远程 JVM?

标签 java jconsole

我有一个在远程 Linux 服务器上运行的 Java 8 应用程序,需要将 JConsole 附加到它以进行调试。

我从本地计算机设置了到远程计算机的隧道:

 ssh -fN -L 9999:localhost:9999 myuser@1.11.11.111

在远程计算机上,我使用以下系统属性运行应用程序:

java -Dcom.sun.management.jmxremote.port=9999 \
-Dcom.sun.management.jmxremote.authenticate=false \ 
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.local.only=false \
-cp foo.jar:config com.foo.bar.Main config/blah.properties

但是当我启动 JConsole 时,我得到安全连接失败。

enter image description here

如果我点击“不安全连接”,我会得到

enter image description here

我该如何解决这个问题?

最佳答案

我成功地为 RMI 端口添加了一个额外的系统属性,使其正常工作:

java \
-Dcom.sun.management.jmxremote.port=9999 \
-Dcom.sun.management.jmxremote.rmi.port=9999 \
-Dcom.sun.management.jmxremote.authenticate=false \ 
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.local.only=false \
-cp foo.jar:config com.foo.bar.Main config/blah.properties

关于java - 如何将 JConsole 连接到远程 JVM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29983262/

相关文章:

jmx - 如何为自定义处理器定义新指标(并使它们在 jconsole 中可用)?

java - 想使用JConsole进行性能测试

java - JConsole 在 Linux 中的位置

java - 禁用 Android 中的通知声音

java - 无法解析 Spring Controller 中的本地日期时间

java - 如何运行已粘贴到我的程序中的 Java 代码

Java:一行中多个++增加。第一个是哪一个?

java - Robot框架如何在两台不同的机器上实现并行测试执行?

java - JVM 选项 -Xms 和 -Xmx 被忽略