Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Enabling JMX RMI on remote resources

Lahiru Pathirage edited this page Apr 2, 2017 · 1 revision

Java applications

To enable JMX remote on a java application, use following parameters on your behalf.

java -Dcom.sun.management.jmxremote \
  -Djava.rmi.server.hostname=127.0.0.1 \
  -Dcom.sun.management.jmxremote.port=9999 \
  -Dcom.sun.management.jmxremote.local.only=false \
  -Dcom.sun.management.jmxremote.authenticate=false \
  -Dcom.sun.management.jmxremote.ssl=false \
  -jar YourApplication.jar

Tomcat

On your tomcat's bin directory, add the above parameters to setenv.sh file if you are in a Unix environment or to setenv.bat if you are in a Windows environment on your behalf. Create setenv files if they do not exists.

  • setenv.sh
export JAVA_OPTS="-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
  • setenv.bat
set CATALINA_OPTS=-Dcom.sun.management.jmxremote
  -Dcom.sun.management.jmxremote.port=9999
  -Dcom.sun.management.jmxremote.ssl=false
  -Dcom.sun.management.jmxremote.authenticate=false

Wildfly/JBOSS

Add following configurations to the JVM specific options area in the standalone.conf if Unix or standalone.conf.bat if Windows.

  • standalone.conf
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
   JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
   
   JBOSS_LOG_MANAGER_LIB="$(echo $JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-*.jar)" # resolve logmanager jar
   JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_LOG_MANAGER_LIB"
   JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager"
   JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"  
   
   JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=7091"
   JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.rmi.port=7091"
   JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
   JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"

   echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
  • standalone.conf.bat
rem # Put log manager lib path here
set "JAVA_OPTS=%JAVA_OPTS% -Xbootclasspath/p:PATH_TO_JBOSS_LOG_MANAGER_LIB"
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager"
set "JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.jboss.logmanager.LogManager"

set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=7091"
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.rmi.port=7091"
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false"
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false"