Unable to Connect to Tomcat Using VisualVM

duckus picture duckus · Jun 27, 2009 · Viewed 25.7k times · Source

I am having problems monitoring a remote Tomcat process. I'm trying to use the Java 6 versions of JConsole/JVisualVM.

I have jstatd running on the remote server with the appropriate security policy. The process is started and the TCP connections are available.

When I try to connect through JConsole, I get 'Connection Failed:jmxrmi'.

When I try to connect through VisualVM, I add the host name and my right-click options are 'Add JMX Connection'. It's unclear to me from the docs whether or not that's what I'd expect to see. When I try to connect, I get:

'Cannot connect using service:jmx:rmi:///jndi/rmi://<host>:<port>/jmxrmi'.

So, the docs suggest I only need have jstatd running remotely to monitor in VisualVM, while the UI is asking for jmxrmi .. Are those the same? I've tried setting up tomcat using jmx rmi options and I also timeout, though I know it's not a firewall issue.

If anyone has had success getting a remote Tomcat process attached in this manner, and could describe how, that would help me out a great deal.

Answer

Tom picture Tom · Feb 5, 2012

Usually you need to make sure you specify the server's ip address in the JAVA_OPTS. Otherwise, it appears that JMX is going to send back instructions to the client to reconnect to the server on a different port and if it doesn't have the ip address to give the client, the connection fails.

The argument for this is:

-Djava.rmi.server.hostname=1.2.3.4

You can find more details in this walk through of the setup process.