javajmxjconsole

Debugging JConsole Connection Failed


I have a web application deployed to a remote resin server, and it has JMX turned on.

I can telnet to the remote server i.e

franz@see:/tmp$ telnet <remote-ip> 5555
Trying <remote-ip>...
Connected to <remote-ip>.
Escape character is '^]'.
��sr5javax.management.remote.message.HandshakeBeginMessage�,���6profilestLjava/lang/String;Lversionq~xppt1.0^]

telnet> q
Connection closed.

But I cannot connect to it using my JConsole

$JAVA_HOME/bin/java -cp $JAVA_HOME/lib/jconsole.jar:$JAVA_HOME/lib/tools.jar:pm-common/lib/jmxremote_optional-1_0_1_3.jar sun.tools.jconsole.JConsole service:jmx:jmxmp://<remote-ip>:5555

I have tried this with the following java versions but I get a 'Connection Failed' on both instances.

## where JAVA_HOME=/opt/java/64/jdk1.5.0_22
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)

## where JAVA_HOME=/opt/java/64/jdk1.6.0_17
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)

Do you guys have any idea as to how to debug this (i.e. find out what's wrong)?


Solution

  • 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.