JBoss (JMX)

Configuring Java Virtual Machines for JMX

The SAM Java application Server (JMX) template allows you to monitor vital statistics from Java Virtual Machines (JVM). Before assigning the template to a node with a JVM you want to monitor, you must configure the target JVM to accept remote JMX queries.

The sections below discuss how to configure JVM servers for JMX monitoring JBoss. Configuration instructions are given for both Linux and Microsoft Windows operating systems.

·         Explaining Java arguments.

·         Configuring a Standalone Java Virtual Machine

·         Configuring JBoss (tested on versions 6.1)

Java Arguments

For enabling remote JMX monitoring, use the following Java arguments:

-Djava.rmi.server.hostname=192.168.0.236
This line indicates the IP address the RMI server will use. Enter your server IP address.

-Dcom.sun.management.jmxremote
This line enables remote JMX monitoring.

-Dcom.sun.management.jmxremote.port=8686
This line indicates which port the JMX module will use to accept JMX connections.

-Dcom.sun.management.jmxremote.ssl=false
This line indicates whether or not SSL is used.

-Dcom.sun.management.jmxremote.authenticate=true
This line indicates whether or not authentication is used. Authentication is recommended. If you do not want to use authentication, enter a value of false.

-Dcom.sun.management.jmxremote.password.file=c:\jmxremote.password
This line indicates where the passwords file is stored. Do not add this line if you do not use authentication.

-Dcom.sun.management.jmxremote.access.file=c:\jmxremote.access
This line indicates where the access file is stored. Do not add this line if you do not use authentication.

Additional information can be found at the following web page: http://docs.oracle.com/javase/1.5.0/docs/guide/management/agent.html.

Configuring a Standalone Java Virtual Machine

Windows

1.   Download the JDK from the Oracle website: http://www.oracle.com/technetwork/java/javase/downloads/index.html(tested on JDK 1.7.0, update version 3).

2.   Install the JDK.

3.   On the license agreement page, read and accept the license and the click Next.

4.   Click Change to change the installation directory to C:\Program Files\Java\jdk1.7.0_3, and then click OK.

5.   Click Next.

6.   Click Finish to exit from the installer.

7.   Add a variable to the system with its path pointing to the JDK installation folder.

      For example:

Variable name: JAVA_HOME
Variable value:  C:\Program Files\Java\jdk1.7.0_3

Note: If you want to run Java commands from the command line, you should add the JDK installation path to the PATH variable.

If you use JMX authentication follow the steps 8-12.

8.   Navigate to the %JAVA_HOME%\jre\lib\management folder.

9.   Rename the jmxremote.password.templatefile to jmxremote.password. Edit jmxremote.passwordby replacing/adding its content with the following:

samuser somepasswd

Where samuser is the JVM user SAM will monitor and somepasswd is the user password.

10Edit jmxremote.accessby replacing/adding its content with the following:

samuser readonly

Where samuser is the JVM user SAM will monitor and readonly gives this user read only permissions.

11Copy jmxremote.access and jmxremote.password a some folder, for example c:\jmxremote\.

12Grant access to the jmxremote.passwordfile only for the Administrator. To grant access only for the Administrator, refer to the following instructions: http://download.oracle.com/javase/6/docs/technotes/guides/management/security-windows.html

Linux:

1.   Download the JDK from the Oracle website: http://www.oracle.com/technetwork/java/javase/downloads/index.html(tested on JDK SE 6, update version 24).

2.   Unpack and run the JDK. In this case, the JDK was installed into the /usr/java/jdk1.7.0_3 folder.

3.   Move this folder to /usr/local.

4.   In the /usr/local/directory, create a symbolic link to jdk1.7.0_3 named Java. Now the JDK is installed in /usr/local/jdk1.7.0_3and linked to /usr/local/java.

5.   Add the /usr/local/java/binfolder to the system path. (If it is only for your account, add it in .bash_profilefile in your home directory). In Slackware, it should be in the .profilefile. To make it a system wide environment, add it in the /etc/profile.

6.   Edit a line in .bash_profileto be similar to: PATH=$PATH:$HOME/bin:/usr/local/java/bin. The path will be automatically set at boot time. To set the path immediately, use the command:
$ export PATH=$PATH:/usr/local/java/bin

7.   Add a variable to the system with the path pointing to the JDK installation folder.

8.   Add the following lines to the /etc/profile file. Syntax dependencies may be different in various Linux distributions. This example is shown for the CentOS system:

export JAVA_HOME=/usr/java/jdk1.7.0_3

export PATH=$PATH:/usr/java/jdk1.7.0_3

To set this immediately, run the export commands in your shell. Or, logout then log back in to your system.

If you use JMX authentication follow the steps 9-13.

9.   Go to the $JAVA_HOME/jre/lib/management folder and rename the jmxremote.password.template file to jmxremote.password.

10Edit jmxremote.passwordby replacing/adding its content with the following:

samuser somepasswd

Where samuser is the JVM user SAM will monitor and somepasswd is the password.

11. Edit jmxremote.access by replacing/adding its content with the following:

samuser readonly

Where samuser is the JVM user SAM will monitor and readonly gives this user read only permissions.

12Copy jmxremote.access and jmxremote.password to a folder, for example /jmxremote/.

13Grant access to the jmxremote.password file only for the root user. Run the following commands as the root user in your shell:

# chown root.root $JAVA_HOME/jre/lib/management/jmxremote.password
# chmod 600 $JAVA_HOME/jre/lib/management/
jmxremote.password

Testing a Standalone JVM

You can test that your JVM can respond to JMX queries by adding the following to the java command line. This will enable JMX on port 8686 using authentication:

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8686 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file="c:\jmxremote\jmxremote.password" -Dcom.sun.management.jmxremote.access.file="c:\jmxremote\jmxremote.access"

For example:

java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8686 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file="c:\jmxremote\jmxremote.password" -Dcom.sun.management.jmxremote.access.file="c:\jmxremote\jmxremote.access"some_java_applet

In a separate window/shell, run the following command to test JMX and the JDK configurations:
%JAVA_HOME%\jdk1.7.0_3\bin\jconsole

In the jconsolewindow, select Remote Process, type 127.0.0.1:8686 and provide Username samand Password somepasswd.

After a successful connection, you will be able to see different monitoring statistics.

Configuring JBoss (tested on versions 6.1)

Windows Command Line:

1.     Edit %JBOSS_HOME%\bin\run.batby adding the following lines (where %JBOSS_HOME% is the path to your JBoss installation):

set "JAVA_OPTS=%JAVA_OPTS% -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"

set "JAVA_OPTS=%JAVA_OPTS% -Djboss.platform.mbeanserver"

set "JAVA_OPTS=%JAVA_OPTS% -Djava.rmi.server.hostname=192.168.0.236"

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=8686"

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false"

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=true"

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.password.file=" c:\jmxremote\jmxremote.password""

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.access.file="c:\jmxremote\jmxremote.access""

where 192.168.0.236 is the IP address of JBoss server.

The above lines should go before the following section:

===============================================================

echo.

echo   JBoss Bootstrap Environment

echo.

echo   JBOSS_HOME: %JBOSS_HOME%

echo.

echo   JAVA: %JAVA%

echo.

echo   JAVA_OPTS: %JAVA_OPTS%

echo.

echo   CLASSPATH: %JBOSS_CLASSPATH%

echo.

echo ===============================================================

2.   Start JBoss by running %JBOSS_HOME%\bin\run.bat.

Linux:

1.   Edit $JBOSS_HOME/bin/run.shby adding the following lines (where $JBOSS_HOME$ is the path to your JBoss installation):

JAVA_OPTS="$JAVA_OPTS -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"

JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver"

JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=192.168.0.236"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=8686"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=true"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.password.file=" /jmxremote/jmxremote.password""

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.access.file=/jmxremote/jmxremote.access""

where 192.168.0.236 is IP address of JBoss server.

The above lines should go before the following section:

# Display our environment

echo "========================================================================="

echo ""

echo "  JBoss Bootstrap Environment"

echo ""

echo "  JBOSS_HOME: $JBOSS_HOME"

echo ""

echo "  JAVA: $JAVA"

echo ""

echo "  JAVA_OPTS: $JAVA_OPTS"

echo ""

echo "  CLASSPATH: $JBOSS_CLASSPATH"

echo ""

echo "========================================================================="

echo ""

2.   Run JBoss by running $JBOSS_HOME/bin/run.sh.

JBoss (JMX)

This template monitors JBoss server statistics by using the JMX protocol. It is recommended that you use this template with the Java Application Server (JMX) template.

Prerequisites: Target JVM configured to allow JMX queries.

Note: This template is configured to send JMX requests on port 8686.

Credentials: Dependent on the JMX configuration.

Note: All monitoring information is taken from the following web page: http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/Additional_Services-Memory_and_Thread_Monitoring.html.

Monitored Components

Note: All components may vary in a running environment. You can add your own threshold limits as needed. For more information, see http://knowledgebase.solarwinds.com/kb/questions/2415.

Active Thread Count

This monitor returns the number of active threads in the JVM.

Active Thread Group Count

This monitor returns the number of active thread groups in the JVM..

Free Memory

This monitor returns the amount of free memory for the JVM this app server instance is running on. This counter should be as high as possible.

Available Processors

This monitor returns the number of available processors.

Max Memory

This monitor returns the amount of max memory for the JVM this app server instance is running on.

Total Memory

This monitor returns the total memory for the JVM this app server instance is running on.

Portions of this document were originally created by and are excerpted from the following sources:

Red Hat, Inc., “JBoss Operations Network,” Copyright Copyright 2012 Red Hat, Inc..  All rights reserved. Available at

http://www.redhat.com/products/jbossenterprisemiddleware/operations-network/l.

  • Hi aLTeReGo​, would like to ask, Is SolarWinds SAM can monitor the RedHat JBOSS Fuse? Thank you!

  • I've been unsuccessful in getting JBoss EAP 6 to start-up with the Sun JMX configuration for Linux, which you have provided here.  I then did some digging on the Red Hat Support site and found that Sun JMX is not supported on EAP 6, as stated here but your guide says you tested it on 6.1?  

    Capture.JPG

    This is the error being thrown at start-up...

    javax.management.JMRuntimeException: Failed to load MBeanServerBuilder class org.jboss.system.server.jmx.MBeanServerBuilderImpl: java.lang.ClassNotFoundException: org.jboss.system.server.jmx.MBeanServ

    erBuilderImpl

            at javax.management.MBeanServerFactory.checkMBeanServerBuilder(MBeanServerFactory.java:503)

            at javax.management.MBeanServerFactory.getNewMBeanServerBuilder(MBeanServerFactory.java:539)

            at javax.management.MBeanServerFactory.newMBeanServer(MBeanServerFactory.java:316)

            at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:231)

            at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:192)

            at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:466)

            at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:453)

            at sun.management.Agent.startAgent(Agent.java:260)

            at sun.management.Agent.startAgent(Agent.java:456)

    Caused by: java.lang.ClassNotFoundException: org.jboss.system.server.jmx.MBeanServerBuilderImpl

            at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

            at java.security.AccessController.doPrivileged(Native Method)

            at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

            at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

            at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

            at javax.management.MBeanServerFactory.loadBuilderClass(MBeanServerFactory.java:446)

            at javax.management.MBeanServerFactory.checkMBeanServerBuilder(MBeanServerFactory.java:488)

            ... 8 more

    Exception thrown by the agent : javax.management.JMRuntimeException: Failed to load MBeanServerBuilder class org.jboss.system.server.jmx.MBeanServerBuilderImpl: java.lang.ClassNotFoundException: org.j

    boss.system.server.jmx.MBeanServerBuilderImpl