References > Template Reference > Configuring Java Applications Servers for JMX

Configuring Java Application Servers for JMX

A Java Management Extension (JMX) allows remote clients to connect to a Java Virtual Machine (JVM). The SAM JMX template allows you to monitor vital statistics from JVM. Before assigning the template to a node with a JVM, configure the target JVM to accept remote JMX queries.

This section describes how to configure JVM servers for JMX monitoring including servers embedded with JBoss, Glassfish, IBM Websphere, and Oracle Weblogic. 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)
  • Configuring GlassFish (tested on version 3.1)
  • Configuring IBM WebSphere (tested on version 8.0)
  • Configuring Oracle WebLogic (tested on version 12)

Java Arguments

For enabling remote JMX monitoring, the following Java arguments will be used:

-Djava.rmi.server.hostname=192.168.0.236

This line indicates the IP address the RMI server will use. Type your server IP address here.

-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. Use of authentication is recommended. If you do not want to use authentication, you should change the value to 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 are not using 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 are not using authentication.

More information can be found at the following website: http://docs.oracle.com/en/.

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 then 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 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

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

If you plan to use JMX authentication:

  1. Navigate to the %JAVA_HOME%\jre\lib\management folder.
  2. Rename the jmxremote.password.templatefile to jmxremote.password. Edit jmxremote.password by replacing/adding its content with the following: samuser somepasswd
    where samuser is the user for the JVM monitored from SAM and somepasswd is the password.
  3. Edit jmxremote.access by replacing/adding its content with the following: samuser readonly
    where samuser is user for the JVM monitored and readonly gives this read only permissions.
  4. Copy jmxremote.access and jmxremote.password to a folder, for example c:\jmxremote\.
  5. Grant access to the jmxremote.password file only for the Administrator. To grant access only for the Administrator, refer to this topic at the following location: 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_3 and linked to /usr/local/java.
  5. Add the /usr/local/java/bin folder to the system path. (If it is only for your account, add it in .bash_profile file in your home directory). In Slackware, it should be in the .profile file. To make it a system wide environment, add it in the /etc/profile.
  6. Edit a line in .bash_profile to 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 following 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:

  1. Go to the $JAVA_HOME/jre/lib/management folder and rename the jmxremote.password.template file to jmxremote.password.
  2. Edit jmxremote.password by replacing/adding the content with the following:
    samuser somepasswd
    where samuser is the user for the JVM monitored from SAM and somepasswd is the password.
  3. Edit jmxremote.access by replacing/adding the content with the following:
    samuser readonly
    where samuser is user for the JVM monitored and readonly - gives this read only permissions.
  4. Copy jmxremote.access and jmxremote.password to a folder, for example /jmxremote/.
  5. Grant 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 jconsole window, select Remote Process, type 127.0.0.1:8686 and provide Username: sam and Password: somepasswd. After a successful connection, you will be able to see different monitoring statistics.

Configuring JBoss (tested on version 6.1)

Windows Command Line:

Edit %JBOSS_HOME%\bin\run.bat by adding the following lineswhere %JBOSS_HOME% is the path to your JBoss installation and where 192.168.0.236 is the IP address of the JBoss server:

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""

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.
=====================================================================

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

Linux

Edit $JBOSS_HOME/bin/run.sh by adding the following lines where $JBOSS_HOME$ is the path to your JBoss installation and where 192.168.0.236 is the IP address of JBoss server:

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""

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 ""

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

Configuring GlassFish (tested on version 3.1)

  1. Run the GlassFish Application Server.
  2. Open a web browser and then navigate to: http://hostname:4848where hostname which is the name of your GlassFish server.
  3. In the left panel, click Configurations: server-config.
  4. In the main window, click JVM settings.
  5. Click the JVM Options tab.
  6. Click Add JVM Option and then type: Dcom.sun.management.jmxremote in the blank field.
  7. Click Add JVM Option and then type: Djava.rmi.server.hostname=192.168.0.236 in the blank field, where 192.168.0.236 is IP address of GlassFish server.
  8. Click Add JVM Option and then type: Dcom.sun.management.jmxremote.port=8686 in the blank field.
  9. Click Add JVM Option and then type: Dcom.sun.management.jmxremote.ssl=false in the blank field.
  10. Click Add JVM Option and then type: Dcom.sun.management.jmxremote.authenticate=true in the blank field.
  11. Click Add JVM Option and then type: Dcom.sun.management.jmxremote.password.file="c:/jmxremote/jmxremote.password" in the blank field.
  12. Click Add JVM Option and then type: Dcom.sun.management.jmxremote.access.file=" c:/jmxremote/jmxremote.access" in the blank field.
  13. Click Save.
  14. Restart the GlassFish server.

Configuring IBM WebSphere (tested on version 8.0)

  1. Run the IBM WebSphere Application Server.
  2. Open a web browser and then navigate to: https://hostname:9043 where hostname is the name of the IBM WebSphere server.
  3. In the left panel, click Expand Servers and Server types.
  4. Click WebSphere Application Servers.
  5. In the main window, click your server.
  6. In the Server Infrastructure section, expand Java and Process Management.
  7. Click Process Definition.
  8. In the Additional Properties section, click Java Virtual Machine.
  9. In Generic JVM Arguments, add the following:

    This will enable JMX without authentication

    -Djavax.management.builder.initial= -Djava.rmi.server.hostname=192.168.0.236 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8686 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false

  10. Click OK.
  11. Click Save and then click OK.
  12. Click Save.
  13. Restart the IBM WebSphere Application Server.

If you have errors after these configuration changes, you can manually change/restore the configuration. These changes are stored in the following file:

%WEBSPHERE_HOME%\profiles\your_profile\config\cells\your_cell\nodes\your_node\servers\your_server\server.xml

Configuring Oracle WebLogic (tested on version 12)

Windows

Edit the following file:
%MIDDLEWARE_HOME%\user_projects\domains\<your_domain>\bin\startWebLogic.cmd
where %MIDDLEWARE_HOME% is the path to your WebLogic installation, by adding the following lines:

set "JAVA_OPTIONS=%JAVA_OPTIONS% -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.port=8686"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.ssl=false"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.authenticate=true"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.password.file="c:\jmxremote\jmxremote.password""
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.access.file=" c:\jmxremote\jmxremote.access""

The result should resemble:

…
call "%DOMAIN_HOME%\bin\setDomainEnv.cmd" %*
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.port=8686"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.ssl=false"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.authenticate=true"
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.password.file=" c:\jmxremote\jmxremote.password""
set "JAVA_OPTIONS=%JAVA_OPTIONS% -Dcom.sun.management.jmxremote.access.file=" c:\jmxremote\jmxremote.access""
set SAVE_JAVA_OPTIONS=%JAVA_OPTIONS%
…

This file is created by the Configuration Wizard. Your changes to this script will be lost the next time you use the configuration wizard.

Restart the WebLogic Server.

Linux

Edit the following file:
$MIDDLEWARE_HOME/user_projects/domains/<your_domain>/bin/startWebLogic.sh
where $MIDDLEWARE_HOME is the path to your WebLogic installation, by adding the following lines:

JAVA_OPTIONS="$JAVA_OPTIONS-Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
JAVA_OPTIONS="$JAVA_OPTIONS -Dcom.sun.management.jmxremote"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.port=8686"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.authenticate=true"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.password.file="/jmxremote/jmxremote.password""
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.access.file="/jmxremote/jmxremote.access""

The result should resemble:

…
. ${DOMAIN_HOME}/bin/setDomainEnv.sh $*
JAVA_OPTIONS="$JAVA_OPTIONS-Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.port=8686"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.authenticate=true"
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.password.file="/jmxremote/jmxremote.password""
JAVA_OPTIONS="$JAVA_OPTIONS-Dcom.sun.management.jmxremote.access.file="/jmxremote/jmxremote.access""
SAVE_JAVA_OPTIONS="${JAVA_OPTIONS}"
…

This file is created by the Configuration Wizard. Your changes to this script will be lost the next time you use the configuration wizard.

Restart the WebLogic Server.

Java Application Server (JMX)

This template assesses the overall performance of Java Application Servers by using JMX protocol. The following application servers are supported: Apache Tomcat, JBoss, GlassFish, IBM WebSphere andOracle WebLogic.

Prerequisites: Target JVM configured to allow JMX queries.

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

Credentials: Dependent on the JMX configuration.

All monitoring information is taken from: http://docs.oracle.com/javase/1.5.0/docs/guide/management/overview.html.

Monitored Components

All components may vary from a running environment. You can add your own threshold limits as necessary. For more information, see "Using the Orion APM Min/Max/Average statistics data for creating threshold settings" in the SolarWinds Success Center.

Classes Loaded Count

This monitor returns the number of classes that are currently loaded in the Java virtual machine.

Classes Total Loaded Count

This monitor returns the total number of classes that have been loaded since the Java virtual machine has started execution.

Classes Unloaded Count

This monitor returns the total number of classes unloaded since the Java virtual machine has started execution.

Memory Pending Final Count

This monitor returns the approximate number of objects for which finalization is pending.

Memory Heap Init Size (B)

This monitor returns the initial amount of memory in bytes that the Java virtual machine allocates; or -1 if undefined.

Memory Heap Used (B)

This monitor returns the amount of used memory in bytes. The amount of used memory in the returned memory usage is the amount of memory occupied by both live objects and garbage objects that have not been collected, if any.

Memory Heap Committed (B)

This monitor returns the amount of committed memory in bytes.

Memory Heap Max Size (B)

This monitor returns the maximum amount of memory in bytes that can be used; or -1 if undefined.

Memory Non Heap Init Size (B)

This monitor returns the initial amount of memory in bytes that the Java virtual machine allocates; or -1 if undefined.

Memory Non Heap Used (B)

This monitor returns the amount of used memory in bytes.

Memory Non Heap Committed (B)

This monitor returns the amount of committed memory in bytes.

Memory Non Heap Max Size (B)

This monitor returns the maximum amount of memory in bytes that can be used; or -1 if undefined.

Memory Garbage Collections Count

This monitor returns the approximate accumulated collection elapsed time in milliseconds.

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.lang, and GarbageCollector and check which names are available. By default, this counter uses: name=Copy.

Memory Garbage Collection Time (ms)

This monitor returns the approximate accumulated collection elapsed time in milliseconds.

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.lang, and GarbageCollector and check which names are available. By default, this counter uses: name=Copy.

Memory Pool Init Size (B)

This monitor returns the initial amount of memory (in bytes) that the Java virtual machine requests from the operating system for memory management during startup. The Java virtual machine may request additional memory from the operating system and may also release memory to the system over time. The value of init may be undefined.

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.langand MemoryPool and check which names are available. By default, this counter uses: name=Code Cache.

For IBM WebSphere, this counter is unavailable and you should disable it.

Memory Pool Used (B)

This monitor returns the amount of memory currently used (in bytes).

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.langand MemoryPool and check which names are available. By default, this counter uses: name=Code Cache.

For IBM WebSphere, this counter is unavailable and you should disable it.

Memory Pool Committed Size (B)

This monitor returns the amount of memory (in bytes) that is guaranteed to be available for use by the Java virtual machine. The amount of committed memory may change over time (increase or decrease). The Java virtual machine may release memory to the system and committed could be less than init. committed will always be greater than or equal to used.

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.langand

MemoryPool and check which names are available. By default, this counter uses: name=Code Cache.

For IBM WebSphere, this counter is unavailable and you should disable it.

Memory Pool Max Size (B)

This monitor returns the maximum amount of memory (in bytes) that can be used for memory management. Its value may be undefined. The maximum amount of memory may change over time if defined. The amount of used and committed memory will always be less than or equal to max if max is defined. A memory allocation may fail if it attempts to increase the used memory such that used > committed even if used <= max would still be true (for example, when the system is low on virtual memory).

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.lang and MemoryPool and check which names are available. By default, this counter uses: name=Code Cache.

For IBM WebSphere, this counter is unavailable and you should disable it.

Memory Pool Peak Used (B)

This monitor returns the peak amount of memory currently used (in bytes).

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.lang and MemoryPool and check which names are available. By default, this counter uses: name=Code Cache.

For IBM WebSphere, this counter is unavailable and you should disable it.

Memory Pool Peak Committed (B)

This monitor returns the peak amount of memory (in bytes) that is guaranteed to be available for use by the Java virtual machine. The amount of committed memory may change over time (increase or decrease). The Java virtual machine may release memory to the system and committed could be less than init. committed will always be greater than or equal to used.

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.lang and MemoryPool and check which names are available. By default, this counter uses: name=Code Cache.

For IBM WebSphere, this counter is unavailable and you should disable it.

Memory Pool Peak Max Size (B)

This monitor returns the maximum peak amount of memory (in bytes) that can be used for memory management. Its value may be undefined. The maximum amount of memory may change over time if defined. The amount of used and committed memory will always be less than or equal to max if max is defined. A memory allocation may fail if it attempts to increase the used memory such that used > committed even if used <= max would still be true (for example, when the system is low on virtual memory).

You should set the correct Object Name. You can see which names are available by running the Find Processes, Services, and Performance Counters wizard. In the wizard, expand java.lang and MemoryPool and check which names are available. By default, this counter uses: name=Code Cache.

For IBM WebSphere, this counter is unavailable and you should disable it.

Threads Total Started Count

This monitor returns the total number of threads created and also started since the Java virtual machine started.

Current Thread Count

This monitor returns the current number of live threads including both daemon and non-daemon threads.

Current Thread CPU Time

This monitor returns the total CPU time for the current thread in nanoseconds.

Current Thread User Time

This monitor returns the CPU time that the current thread has executed in user mode in nanoseconds.

Runtime Uptime (ms)

This monitor returns the uptime of the Java virtual machine in milliseconds.

Compiler Time (ms)

This monitor returns the approximate accumulated elapsed time (in milliseconds) spent in compilation.