This short tutorial shows how you can connect to WildFly 8 using VisualVM monitoring tool. 


VisualVM is a visual tool integrating several command line JDK tools and profiling capabilities. You can use it as application developer to monitor, profile, take thread dumps and browse heap dumps. As system administrator you can use it to monitor and control Java applications across the entire network.

VisualVM is included in the JDK bin folder so just move into the JAVA_HOME/bin folder in order to execute it. Since you need to use the http-remoting-jmx protocol in order to connect to WildFly, you have to include the jboss-client.jar in the visualvm classpath. Here is how to do it:

jvisualvm.exe -cp:a c:\wildfly-8.1.0.Final\bin\client\jboss-client.jar

Now, provided that the application server has started, you will be able to see immediately in the left tree panel, under the Local element, the application server process. Click on it in order to start monitoring, profiling it.

visualvm wildfly monitoring visualvm

Connecting to a remote WildFly process

Connecting to a remote WildFly requires a bit of extra work, as a matter of fact you need the jstatd tool which is an RMI server application that monitors for the creation and termination of instrumented HotSpot Java virtual machines (JVMs) and provides a interface to allow remote monitoring tools to attach to JVMs running on the local host. This file needs to be associated with a security policy which allows connections between the client and the remote server. So as first step create on the remote machine (where Wildfly is installed) a file named security.policy which contains the following:


grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};

Now execute jstatd as follows:

jstatd -J-Djava.security.policy=security.policy

Fine, now you can start WildFly, taking care to bind it to an IP address which can be reached from a remote machine:


standalone.bat -b 192.168.118.132 -bmanagement=192.168.118.132

Since we will need a management user to connect to this server, execute the add-user script and create a management user:

$ ./add-user.sh

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a):

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : administrator
The username 'administrator' is easy to guess
Are you sure you want to add user 'administrator' yes/no? yes
Password : 
Re-enter Password :


Done with the server, let's move to the client, where you are running visualvm. Start is as usual with:

jvisualvm.exe -cp:a c:\wildfly-8.1.0.Final\bin\client\jboss-client.jar

Now, in order to connect to a remote server, you need to right-click on the Remote icon in the left tree panel and choose "Add Remote Host":

visualvm wildfly monitoring visualvm

Specify the Host name or IP address (in our case 192.168.118.132) - Please note that by clicking on Advanced Settings you can change the default port settings of jstatd which is 1099

Now right click on the remote machine icon and choose "Add JMX Connection":

Within the Connection settings, you have to specify the URL in this format:
service:jmx:http-remoting-jmx://<host>:<port>
So in our example it would be:  
service:jmx:http-remoting-jmx://192.168.118.132:9990
Specify as well the management username and password as displayed in this picture:

visualvm wildfly monitoring visualvm

As you can see, VisualVM was able to connect to the remote server which is now enlisted beneath the Remote machine:

visualvm wildfly monitoring visualvm

That's all! Enjoy VisualVM with WildFly!

0
0
0
s2smodern

Related articles available on mastertheboss.com

Wildfly 8 introduction

JBoss AS has a new name: as you probably know future versions of

Configuring Eclipse to use WildFly

This tutorial shows how to install JBoss Tools 4.3.1 plugin 

Maven configuration for Java EE 7 projects on WildFly

In this tutorial we will learn how to configure Maven Project Obj

Running WildFly with JDK 8

The JDK 1.8 early access is available for download at Oracle's si

Patching WildFly application server

The final version of WildFly 8.1.0 has been released and it conta

Configuring WildFly Batch Job Repository

WildFly ships with a subsystem named batch which is the administr