How to connect to JBoss EAP 6 / JBoss EAP 7 using VisualVM

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x

Issue

  • Unable to connect to jmx with visualvm
  • How to connect to a JBoss instance remotely using visualvm and jmx connector.
  • Enabled the following JAVA_OPTIONS in the standalone.conf still not able to connect to JBoss EAP6 using VisualVM
JAVA_OPTS="$JAVA_OPTS  -Dcom.sun.management.jmxremote.port=9002"
JAVA_OPTS="$JAVA_OPTS  -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS  -Dcom.sun.management.jmxremote.ssl=false"

Getting the following Exception while starting JBoss EAP 6 using above JAVA_OPTS

./standalone.sh 
=========================================================================
  JBoss Bootstrap Environment
  JBOSS_HOME: /home/userone/JBoss/jboss-eap-6.0
  JAVA: /home/rmartine/Development/jdk1.6.0_30/bin/java
  JAVA_OPTS:  -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9002 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

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

WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
	at org.jboss.as.server.Main.main(Main.java:73)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.jboss.modules.Module.run(Module.java:260)
	at org.jboss.modules.Main.main(Main.java:291)
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
	at org.jboss.logmanager.Logger.getLogger(Logger.java:60)
	at org.jboss.logmanager.log4j.BridgeRepositorySelector.<clinit>(BridgeRepositorySelector.java:42)

  • How to monitor EAP 6 using VisualVM?
  • Unable to use JVisualvm when JBoss is running as windows service.
  • How to run Visual VM on Jboss EAP 6 ?
  • Require Instructions on how to run Visual VM on Jboss 6.3 EAP.
  • Visual VM on Jboss 6.3 EAP.

Resolution

PLEASE NOTE: the below is an example only. The scripts in question are examples and as such not supported. We will make a commercially reasonable effort if there are any real issues with it (likely only dealt with by the developer who created them).
But you are free to use them as a basis to make other JMX based tools connect to JBoss EAP.

To connect to JBoss EAP6 using VisualVM, use the attached scripts (jvisualvm.sh / jvisualvm.bat). They work with all versions of EAP 6.x

Start the EAP server with a bind address for (at least) the management interface. For example:

  `./standalone.sh  -bmanagement 192.168.1.1`

or if you only want to use a local connection, use localhost in the below service URL

Local connections

  • Copy jvisualvm.sh to $JBOSS_HOME/bin

  • Make sure you have a valid Management User who can connect to JBoss (not using the $local mechanism)

  • Run the script $JBOSS_HOME/bin/jvisualvm.sh

  • In the VisualVM GUI choose File --> Add JMX Connection ...

  • Enter the connection URL and specify a valid username and password

  • EAP 6 and EAP 7 using the native management interface. Note that on EAP 7 standalone mode, this interface is not present, but can be added.

    service:jmx:remoting-jmx://jbosshost:9999
  • EAP 7 using the http management interface:
service:jmx:remote+http://jbosshost:9990

Connecting to Domain managed servers

  • Use the following jmx subsystem configuration:

          <subsystem xmlns="urn:jboss:domain:jmx:1.3">
              <expose-resolved-model/>
              <expose-expression-model/>
              <remoting-connector use-management-endpoint="false"/>  
          </subsystem>
    
  • Use the jvisualvm script as described above for EAP 6.x, but connect to the remoting port (default 4447 plus any offset):

      service:jmx:remoting-jmx://jbosshost:4447+anyportoffset
    
  • Use the jvisualvm script as described above for EAP 7.x, but connect to the remoting port (default 8080 plus any offset):

      service:jmx:remote+http://jbosshost:8080+anyportoffset
    

Remote Connections

When using JBoss EAP 6.0.0 or 6.0.1 you need to install a full instance. This is due to the dependency on multiple libraries in the modules directory.
Then use jvisualvm.sh as per above pointing it to the remote instance.

When using 6.1.0 and up, you only need to copy $JBOSS_HOME/bin/client/jboss-cli-client.jar to your box
The script assumes that jar will be in that directory, so recreate the structure:

    $JBOSS_HOME/bin/client/jboss-cli-client.jar
    $JBOSS_HOME/bin/jvisualvm.sh
  • Run the script $JBOSS_HOME/bin/jvisualvm.sh

  • In the VisualVM GUI choose File --> Add JMX Connection ...

  • Enter the connection URL and specify a valid username and password

With RBAC

If RBAC feature is enabled, user or group should be added to proper property file and additionally the user or group has to have at least an role.

For example, if remoting port is used, the user/group information should be in application-users.properties/application-roles.properties. However, if management port is used as default, the information should be in mgmt-users.properties/mgmt-groups.properties.
Then, the added user/group has to have one of roles such as SuperUser like following, otherwise it is not possible to access to jmx mbean so you will see blank page in Thread tap on visualvm.

<access-control provider="rbac">
    <role-mapping>
         <role name="SuperUser">
            <include>
               <user realm="ApplicationRealm" name="jboss"/>
            </include>
          </role>
     <role name="Operator">
</access-control>

Diagnostic Steps

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.