Not able to Connect a Remote Host to the VisualVM

rushi picture rushi · Oct 24, 2011 · Viewed 33.2k times · Source

I am new to Java and I'm facing a problem in connecting a Remote Host to the JVisualVM.

I've searched the Internet and followed all the steps mentioned there but still am not able to resolve the issue. The steps I followed are:

  1. I started the jstatd on the remote server by first creating a jstatd.all.policy file in the $JAVA_HOME/bin. The file contained: grant codebase "file:${java.home}/../lib/tools.jar" { permission java.security.AllPermission;};

  2. I started the Jstatd as jstatd -J-Djava.security.policy=jstatd.all.policy

  3. I started the Java application on the remote host as :

    java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false application_name
    
  4. I then started as instance of the JVisualVM on my local machine and as I added the remote host, it got connected but i wasn't able to see any of the Java processes.

Can anyone please help me with this.

Thanks.

Answer

Jacek Milewski picture Jacek Milewski · Feb 25, 2012

I encountered similar problems when connecting to Glassfish application server. See solutions that worked for me as they can be same for You:

  • Try setting on your application:

-Djava.rmi.server.hostname=*Remote_Server_External_IP_Address* The mentioned IP address should be server external IP (may sound silly but it worked for me). The main problem in my case was JMX pointing to the localhost and looping. In config files the exact IP address should be set to the remote host. I described it as 'Problem 2' In my blog: handling connection problems

  • If Firewall block is an issue then I recommend trying XMing with SSH tunnel (which is simple to set). Here is instruction, if You encounter problems setting it:
    Remote use of VisualVM with Xming (my blog) Biggest advantage of using XMing is that it will work almost always when SSH is enabled. You just have to place VisualVM files on the remote host and run it from command line. XWindow will show VisualVM Window on Your local computer.

  • There is a chance that it is VisualVM issue - try using some other tool just to verify what is wrong. I recommend JConsole. It works similar to VisualVM and I also described details on my blog