VisualVM is a useful tool for monitoring and simple profiling of JVM processes. It integrates various command line tools of the JDK such as jstat, jinfo, jstack into a graphical UI. The tool is part of the JDK since 1.6.0_07.

VisualVM discover local and remote JVM processes. There are two different way to connect a remote host and JVM processes:

jstatd connection jmx connection

To auto discover remote processes it is necessary to start a jstat daemon with the appropriate security policy for native permissions. But this is out of scope in this post. We will cover and explain how to create a JMX connection to an EAP6 instance or respectively a JBoss AS7 instance with VisualVM. This has also the benefit, that we can use more capabilities of VisualVM and we get more information for profiling.

Connecting a remote EAP6 / AS7 JVM process

Connecting VisualVM to a remote EAP6 / AS7 JVM process is quit easy. The application server supports the JMX Remote API for remote management and monitoring (JSR 160). Therefor, JBoss implements a JSR 160 compliant JMXConnector instead of an RMI interface to establish a connection to a JMX MBeanServer form a remote client. There is no need for any additional JVM options. The JMXConnector uses under the hood JBoss Remoting for the transport and by default the native management endpoint of the AS7 if the server is running in the standalone mode. To access the management endpoints a management user in the realm ManagementRealm is required. If no user exists, you can use the add-user script from the EAP6 / AS7 distribution. You can create a user as follows:

$JBOSS_HOME/bin/add-user.sh username password

If you are running your server or multiple server instances in the domain mode the JMXConnector uses the remoting connector. To establish a connection over the remoting connector a user in the realm ApplicationRealm is required. You can create a user for the ApplicationRealm with the option -a as follows:

$JBOSS_HOME/bin/add-user.sh -a username password

The configuration is located in the JMX subsystem. You can use the command line interface (CLI) of the application server to see a full description of all possible configurations:

$JBOSS_HOME/bin/jboss-cli.sh [disconnected /] connect --controller ... [standalone@hostname:9999 /] /subsystem=jmx :read-resource-description(recursive=true)

Note that the management interface must be accessible in both modes from a remote client. You can bind the management interfaces at server startup by setting this system property:

Standalone Mode

$JBOSS_HOME/bin/standalone.sh –Djboss.bind.address.management=

Domain Mode

$JBOSS_HOME/bin/domain.sh –Djboss.bind.address.management=

Starting VisualVM with the necessary libraries to connect JMX over JBoss Remoting

As already mentioned before, the JMX MBeanServer is accessible using JBoss Remoting through the management connection. Therefore, it is necessary to add the following libaries from the modules directoriy of the EAP6 / AS7 distribution to the classpath of VisualVM:

org/jboss/remoting3/remoting-jmx

org/jboss/remoting3

org/jboss/logging

org/jboss/xnio

org/jboss/xnio/nio

org/jboss/sasl

org/jboss/marshalling

org/jboss/marshalling/river

To start VisualVM, you can also use the attached script and copy it into the bin directory of the EAP6 / AS7 distribution.

Configure VisualVM for a remote connection

The next step is to add a Remote Host as shown in the following screenshots of VisualVM.

After that you need to configure a JMX connection as shown in the screenshot below. We need to use a JMX Service URL to identify the JSR-160 compliant JMXConnectorServer of the AS7 to establish a connection from VisualVM with the form service:jmx:PROTOCOL://IP:PORT .

The service URL begins always with service:jmx: followed by the protocol, host and port. The protocol is JBoss specific and named remoting-jmx . If you are running the server in the standalone mode the default port of the native management interface is 9999. The default port of the remoting connector in the domain mode is 4447 plus port offset, if configured.

For authentication the credentials of the management user in standalone mode or the credentials of the application user in domain mode are required.

After a successful connection via JMX, you should see the following screen.

That’s it! Feel free to contact us for any questions or feedback.

heinz.wilming (at) akquinet.de