My specific question has to do with JMX as used in JDK 1.6: if I am running a Java process using JRE 1.6 with
com.sun.management.jmxremote
in the command line, does Java pick a default port for remote JMX connections?
Backstory: I am currently trying to develop a procedure to give to a customer that will enable them to connect to one of our processes via JMX from a remote machine. The goal is to facillitate their remote debugging of a situation occurring on a real-time display console. Because of their service level agreement, they are strongly motivated to capture as much data as possible and, if the situation looks too complicated to fix quickly, to restart the display console and allow it to reconnect to the server-side.
I am aware the I could run jconsole on JDK 1.6 processes and jvisualvm on post-JDK 1.6.7 processes given physical access to the console. However, because of the operational requirements and people problems involved, we are strongly motivated to grab the data that we need remotely and get them up and running again.
EDIT: I am aware of the command line port property
com.sun.management.jmxremote.port=portNum
The question that I am trying to answer is, if you do not set that property at the command line, does Java pick another port for remote monitoring? If so, how could you determine what it might be?
So, the short answer to my question is "no."
However, it's interesting to examine why. Look at the
netstat
output from a valid local connection. Here are the ports that I see opened up as a result of ajconsole
making a local connection to itself. As you can see, port 1650 is the local port being used for the JMX information:However, it's not sufficient to try to connect
jconsole
tolocalhost:1650
. Sadly, all that will net you is a "Connection failed: no such object in table" message.So, the conclusion of my original story is that, if we are going to facilitate remote monitoring using JMX for our customers, we really need to identify unique individual remote access ports for the variety of Java processes that are started in our system. Fortunately, all this requires is the judicious use of the VM argument:
where we will almost certainly have a sequential pre-specified range of
portNum
so that the customer can select the correct remote application using the port number.