Connecting VisualVM with a remote JBoss AS 7 / EAP6 JVM process

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 start screen
VisualVM start screen

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

  1. jstatd connection
  2. 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.

$JBOSS_HOME/bin/visualvm.sh

Configure VisualVM for a remote connection

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

visualvm - add a remote host
add a remote host (1)
visualvm - add a remote-host
add a remote host (2)

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.

visualvm - add jmx-connection
add jmx-connection (1)
visualvm - add jmx connection over jboss remoting
add jmx connection over jboss remoting (2)

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.

Connecting visualvm with jbossas7 remote jvm process
VisualVM screen after a successful connection

That’s it! Feel free to contact us for any questions or feedback.
heinz.wilming (at) akquinet.de

9 thoughts on “Connecting VisualVM with a remote JBoss AS 7 / EAP6 JVM process

  1. Is there a way to get the MBeans via RMI or JMXMP?
    Using remoting-jmx with all it’s dependencies is not quite fun for monitoring applications. Thanks for the article.

  2. Do you know if there are any problems when using your method via a SOCKS proxy ? I tried it (because I have a machine behind firewalls where the JBoss AS 7.1.1 is started) and the connection always fails…I did not manage to access it remotely (but web console with my browser configured to use the proxy works).

    Thanks for your guide ;-)

    Andrea

  3. Hi,
    Thank you for the post. Can you also provide the script for Windows for setting the classpath JARs for VisualVM?

    Thanks,
    Rohan

      1. Hi,

        the best way is to copy the jconsole.bat file and change the line
        “%JAVA_HOME%\bin\jconsole.exe” “-J-Djava.class.path=%CLASSPATH%”

        to

        “%JAVA_HOME%\bin\jvisualvm.exe” “–cp:a” “%CLASSPATH%”

        Cheers, Heinz

  4. After struggling for some time, we managed to follow these instructions but we found that a JAR expected to be found in org/jboss/remoting3/remoting-jmx was actually found in org/jboss/remoting-jmx in the JBoss EAP 6.1 we installed locally. After updating jvisualjm.bat accordingly (update call to SearchForJars), we managed to connect to our JBoss instance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s