Debugging JConsole Connection Failed

荒凉一梦 提交于 2019-11-30 04:43:51
samarth

Make sure you are running your application with following java properties set

-Dcom.sun.management.jmxremote.port=9005
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

Try to connect now. If you want to debug this ,you can run the jconsole with following command

jconsole -J-Djava.util.logging.config.file=path_to_logging.properties_for_jconsole

Below is the content of logging.properties file

Logging.properties

handlers = java.util.logging.ConsoleHandler


.level = INFO

java.util.logging.ConsoleHandler.level = FINEST

java.util.logging.ConsoleHandler.formatter = \

java.util.logging.SimpleFormatter

// Use FINER or FINEST for javax.management.remote.level - FINEST is

// very verbose...

javax.management.level = FINEST

javax.management.remote.level = FINER

Once you run jconsole a separate window will pop up displaying logs.

rogerdpack

if you run jconsole -debug it gives you more diagnostic info on the failure. See the Daniel Fuchs blog entry "Troubleshooting connection problems in JConsole".

I did this and it showed me I was using 32 bit jconsole the target process was started with a different (64 bit) jvm, so apparently this isn't allowed and it was thus failing.

This finally made it work for me : Giving this extra option: -Djava.rmi.server.hostname=<ip addres where jvm is running

So all the vm arguments used to open jconsole from a remote machine, the jvm on the remote machine must be started with

 -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.port=<port> -Dcom.sun.management.jmxremote -com.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=<ip address>

The entire process is listed here

I encountered the same Problem when starting the Java-Process through cygwin. JConsole cannot connect. Started it through win7-cmd everything works as expected.

I don't know if this is helpful, but perhaps you should use the the jconsole binary in the JDK bin directory rather than using the undocumented (and subject to change) sun.* classes to start up the console

If your application is running on JDK 1.6 then you should be able to connect it. If it is using JDK prior to 1.6 then run it with specifying the following JVM argument

-Dcom.sun.management.jmxremote

I was having similar issue that remote machine was behind firewall and firewall was blocking ports defined by -Dcom.sun.management.jmxremote.port and RMI 46924. After allowing me to cnnect to these port I connected succesfully.

If you are accessing a machine behind a firewall, you need to open both JMX and RMI ports.
In this context, you are much better off forcing the value for RMI than relying on the auto assigned
In my case, I was trying to access Tomcat so I had to do the following:

#!/bin/sh
CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8008 -Dcom.sun.management.jmxremote.rmi.port=8007 -Dcom.sun.
management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

and then

firewall-cmd --zone=public --add-port=8008/tcp --permanent
firewall-cmd --zone=public --add-port=8007/tcp --permanent
firewall-cmd --reload
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!