javajvmvisualvm

Unable to remote connect VisualVM to CentOS


I am new to VisualVM and trying to monitor some application which is deployed on Tomcat 9 CentOS server. I have installed VisualVM on my Windows laptop and trying to remote connect to the JVM on the CentOS server, but nothing is displayed (message on VisualVM: Not supported for this JVM).

Please find below Java version installed on CentOS server:

[root@localhost bin]# java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

Based on the online resource I saw, I need to enable JMX on Tomcat, so I have added the following properties in my setenv.sh (in tomcat/bin folder) file:

export CATALINA_OPTS="\
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=8999 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false"

I have downloaded the latest VisualVM and created a remote host via File->Add Remote Host. Then Add JMX Connection info as follows:

connection:dymmyip:8999
username  :user
Password  :dummyPassword
uncheck   :do not require ssl

When I try to connect, the following screen is displayed:

enter image description here

Can anyone tell me please what I am missing here?


Solution

  • You can add the missing =true in your setenv.sh

    export CATALINA_OPTS="\
    -Dcom.sun.management.jmxremote=true \
    -Dcom.sun.management.jmxremote.port=8999 \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.local.only=false"
    

    You have to chmod you setenv.sh too:

    $ cd <your-tomcat-dir>/bin
    $ chmod a+x setenv.sh
    

    Be sure it is not a firewall issue. Test the connection with telnet dummyip 8999

    Be sure using the same JVM on both VisualVM and Tomcat. (Be careful with architecture too: 32 or 64bits)

    You can get the last release of VisualVM here.
    To install it:

    $ [ -f "/usr/bin/visualvm" ] && sudo mv /usr/bin/visualvm{,.old}
    $ wget https://github.com/oracle/visualvm/releases/download/2.1.4/visualvm_214.zip
    $ unzip visualvm_214.zip
    $ sudo mv visualvm_214 /opt/
    $ sudo ln -s /opt/visualvm_214/bin/visualvm /usr/bin/
    
    $ visualvm --jdkhome /usr/lib/jvm/java-17-openjdk-amd64
    

    Use the path you want in --jdkhome.