Configuring VisualVM to connect to the app server

Learn how to configure VisualVM in part three of this tutorial.

VisualVM is included with the JDK and is a great tool for monitoring statistics regarding a JVM in real time, including CPU, memory and thread usage. It is running on the Netbeans Rich-Client Platform, which means that there are a number of available plug-ins to extend its functionality, including a plug-in which will allow you to browse the MBeans registered with the server. VisualVM can be configured to monitor both VMs running on the local machine as well as VMs running remotely, assuming the remote application server has been configured to accept remote JMX connections.

In order to install the MBean plug-in, go to the Tools menu in VisualVM, and select the Plugins menu item. On the Plugin dialog that pops up, select the Available Plugins tab, click on the VisualVM-MBeans plug-in and click the Install button at the bottom left of the dialog. Once installed, you can restart VisualVM for the changes to take effect.

If your Java VM (JVM) is running on the local machine, the process will be displayed under the Local node in the Applications tree on the left side of the VisualVM UI. If you need to connect to a remote VM, right click on the Remote node and enter a host name to connect to. Once a host has been added, connections can then be created to various VMs running on that host. Right-click on the host just created and select Add JMX Connection. Specify the JMX port number the JVM is using and any security credentials if needed. At this point you should now be able to connect to the remote VM.

Java VisualVM Figure 1

VisualVM will then attempt to connect to the host at the specified port. If the connection is successful, a new node will appear under the host node indicating a JVM listening at that port. Double clicking the host/port node will bring up the JVM details on the right portion of the UI, including a tab labeled MBeans which will contain information for the application MBean that was created above. 

Java VisualVM Figure 2

More in this tutorial:

Monitor your Web applications using JMX and Spring

Dig Deeper on Front-end, back-end and middle-tier frameworks

App Architecture
Software Quality
Cloud Computing