Monitoring Enonic XP JVM 1.8 with JMX + jconsole/jvisiualvm etc


I’m trying to set up JMX for monitoring and profiling, but the jConsole and jvisualvm just timeout or disconnect when connecting to the port defined in the config. Is this configuration correct? How do you do profiling and monitoring of memory and GC?

I have edited the with the following parameters:
setupDefaults() {
DEFAULT_JAVA_OPTS="-Xms2048M -Xmx3064M -Dfile.encoding=UTF-8"
DEFAULT_JAVA_DEBUG_OPTS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

The port listing shows:
java 2663 vagrant 29u IPv6 17867 0t0 TCP *:1099 (LISTEN)

The enonic /status output is:
gc: {
collectionTime: 409,
collectionCount: 6
jvm: {
name: “Java HotSpot™ 64-Bit Server VM”,
vendor: “Oracle Corporation”,
version: “25.45-b02”,
startTime: 1445332551700,
upTime: 386070
memory: {
heap: {
init: 2147483648,
max: 2856321024,
committed: 2768764928,
used: 228532336
nonHeap: {
init: 2555904,
max: -1,
committed: 94855168,
used: 90439032
os: {
name: “Linux”,
version: “3.13.0-55-generic”,
arch: “amd64”,
cores: 2,
loadAverage: 0.24
systemProperties: {
awt.toolkit: “sun.awt.X11.XToolkit”,
file.encoding.pkg: “”,
java.specification.version: “1.8”,
sun.cpu.isalist: “”,
sun.jnu.encoding: “ANSI_X3.4-1968”, “false”,
java.class.path: “/vagrant/e53/lib/commons-io-2.4.jar:/vagrant/e53/lib/guava-18.0.jar:/vagrant/e53/lib/jansi-1.11.jar:/vagrant/e53/lib/jcl-over-slf4j-1.7.10.jar:/vagrant/e53/lib/jul-to-slf4j-1.7.10.jar:/vagrant/e53/lib/launcher-5.3.1.jar:/vagrant/e53/lib/log4j-over-slf4j-1.7.10.jar:/vagrant/e53/lib/logback-classic-1.1.2.jar:/vagrant/e53/lib/logback-core-1.1.2.jar:/vagrant/e53/lib/org.apache.felix.framework-4.4.1.jar:/vagrant/e53/lib/org.apache.felix.utils-1.6.0.jar:/vagrant/e53/lib/org.osgi.compendium-5.0.0.jar:/vagrant/e53/lib/org.osgi.core-5.0.0.jar:/vagrant/e53/lib/slf4j-api-1.7.10.jar”,
java.vm.vendor: “Oracle Corporation”, “64”,
sun.font.fontmanager: “sun.awt.X11FontManager”,
java.vendor.url: “”,
user.timezone: “Etc/UTC”, “Linux”,
java.vm.specification.version: “1.8”, “US”, “SUN_STANDARD”,
sun.boot.library.path: “/opt/jdk/jdk1.8.0_45/jre/lib/amd64”, “false”, “com.enonic.xp.launcher.LauncherMain debug”, “”,
xp.install: “/vagrant/e53”,
sun.cpu.endian: “little”,
user.home: “/home/vagrant”,
user.language: “en”,
java.specification.vendor: “Oracle Corporation”,
java.home: “/opt/jdk/jdk1.8.0_45/jre”,
file.separator: “/”,
line.separator: "
", “false”,
java.vm.specification.vendor: “Oracle Corporation”, “Java Platform API Specification”,
java.awt.graphicsenv: “sun.awt.X11GraphicsEnvironment”,
java.awt.headless: “true”,
sun.boot.class.path: “/opt/jdk/jdk1.8.0_45/jre/lib/resources.jar:/opt/jdk/jdk1.8.0_45/jre/lib/rt.jar:/opt/jdk/jdk1.8.0_45/jre/lib/sunrsasign.jar:/opt/jdk/jdk1.8.0_45/jre/lib/jsse.jar:/opt/jdk/jdk1.8.0_45/jre/lib/jce.jar:/opt/jdk/jdk1.8.0_45/jre/lib/charsets.jar:/opt/jdk/jdk1.8.0_45/jre/lib/jfr.jar:/opt/jdk/jdk1.8.0_45/jre/classes”, “HotSpot 64-Bit Tiered Compilers”,
java.runtime.version: “1.8.0_45-b14”, “vagrant”,
path.separator: “:”,
os.version: “3.13.0-55-generic”,
java.endorsed.dirs: “/opt/jdk/jdk1.8.0_45/jre/lib/endorsed”, “Java™ SE Runtime Environment”,
file.encoding: “ANSI_X3.4-1968”,
xp.home: “/vagrant/e53/home”, “”, “Java HotSpot™ 64-Bit Server VM”,
java.vendor.url.bug: “”, “/tmp”, “1099”,
java.version: “1.8.0_45”,
user.dir: “/home/vagrant”,
os.arch: “amd64”, “Java Virtual Machine Specification”,
java.awt.printerjob: “sun.print.PSPrinterJob”,
sun.os.patch.level: “unknown”,
java.library.path: “/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib”, “mixed mode”,
java.vendor: “Oracle Corporation”,
java.vm.version: “25.45-b02”,
java.rmi.server.randomIDs: “true”,
java.ext.dirs: “/opt/jdk/jdk1.8.0_45/jre/lib/ext:/usr/java/packages/lib/ext”, “UnicodeLittle”,
java.class.version: “52.0”

The default settings works for me:

-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

Do you run with “debug” option? It has to be set as the first option i think.

Yes, I run the with debug as the first parameter and the options that I define opens the 1099 TCP port, I can see it with lsof. The problem is that the jconsole does not connect. I can see that a connection is being made, but jconsole just gets a disconnected status after a while and no data is being shown.

Remote debugging on port 5005 works. Now I want to connect to JVM’s JMX to monitor and profile to application.

If I just use the default options, I can’t see any special JMX port being opened for remote access. Any tip?

We do not normally use JMX remotely, but last time I tried I used it successfully with the tips from this stack-overflow thread:

Thanks, adding
to the debug options worked :smile: