It is necessary at some point of a project, to analyse consumption of resources by an application.

In Java, we have JMX, which allows to access the internal data of a running JVM (JMX stands for Java Management eXtension). I got so many issues using the recommended configuration, given by wildfly and redhat, to analyse the memory consumption of a Wildfly instance, that I decided to document the steps.

If you look at the wildfly documentation, it well written that you can enable the JMX management by changing the standalone.xml configuration file. It did not work for me (connection refused for all the tested variations).

Setting up the standalone.conf

The standalone.conf is the configuration file responsible of all the parameters passed to the file, itself responsible of the JBOSS startup. Here is the one and only one configuration that did work for me to enable JMX remote access:

#(1) share classloader
if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
# Sample JPDA settings for remote socket debugging
# (2) setup the jmx configuration
# (2.a) begin with logger concerns
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.4.Final.jar"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/log4j/logmanager/main/log4j-jboss-logmanager-1.1.2.Final.jar"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/logging/main/jboss-logging-3.3.0.Final.jar"

# (2.b) JMX setup
JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=<IP>"

Note that the order is really important, it allows the JVM to load the logger early, which is a requirement to correcly setup the JMX configuration and JBOSS at the same time.

  • 1.forces the early loading of the logmanager module
  • 2a.configures the classpath to recognize the logger feature
  • 2b.configures jmx

Start jboss

Simply start JBOSS, you should not see any error regarding the logger


Connect using JConsole

What is good with this technique is that you don't need to configure whatever jboss-client.jar file in the classpath of Jconsole. Simply launch JConsole and type your IP:PORT as follows:

Analysing results

You should be able to follow the evolution of your memory consumption

Previous Post