Java features explained with examples

JMX over RMI

JMX is a technology used to manage and monitor applications running on the JVM. It is used by tools like JConsole and Visual VM. The default communication protocol for remote JMX connections is RMI.

To enable JMX remote connections, the following properties must be set when starting the JVM:

com.sun.management.jmxremote
com.sun.management.jmxremote.port

In the background, an RMI registry is started and listen on the specified port. The port is only used for the registry connection. The actual connections are made on a random port, unless it is set with

com.sun.management.jmxremote.rmi.port

For a client outside the server host’s domain to be able to invoke methods on a server’s remote objects, the client must be able to find the server. To do this, the remote references that the server exports must contain the fully-qualified name of the server host.

How does this affect applications running on Docker containers: by default, applications running in a Docker container will export the Docker-assigned internal IP address. Therefore, it is necessary to set the following property to the externally accessible IP address of the container:

java.rmi.server.hostname

63total visits,1visits today