Skip to main content

Play2

Adding JVM options

This explains how to add required JVM options to effectively use the Java monitoring agent in the Play2 application server environment.

Set the agent options in the $PLAY_HOME/framework/build file. If you have a separate startup or stop script, apply it to that file.

#! /usr/bin/env sh

########## WHATAP START ############
WHATAP_HOME=/apps/whatap
WHATAP_JAR=`ls ${WHATAP_HOME}/whatap.agent-*.jar | sort -V | tail -1`
JAVA_OPTS="${JAVA_OPTS} -Dwhatap.play2=2.2.6 -javaagent:${WHATAP_JAR}"
########## WHATAP END ############

if [ -z "${PLAY_VERSION}" ]; then
PLAY_VERSION="2.2.6"
...
Note

For Play, add the -Dwhatap.play2=2.2.6 option other than the default settings.

Note

In case of Java 17 or later, add the following options for reflection.


--add-opens=java.base/java.lang=ALL-UNNAMED

Viewing the heap histogram

WhaTap's Java Monitoring provides the function to view the status of heap occupancy objects in the JVM memory (sizes for each object in heap memory). In APP > Instance performance analysis, select the Heap histogram tab.

Java versions 6 to 8 support basic functions without the JVM options. However, for some Java versions, the JVM options must be applied as follows:

  • Java 9 to Java 15

    -Djdk.attach.allowAttachSelf=true
    example
    java -javaagent:{WHATAP_HOME}/whatap.agent-X.Y.Z.jar -Djdk.attach.allowAttachSelf=true -jar {application.jar}
  • Java 16 or later

    -Djdk.attach.allowAttachSelf=true
    --add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED
    example
    java -javaagent:{WHATAP_HOME}/whatap.agent-X.Y.Z.jar -Djdk.attach.allowAttachSelf=true --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED -jar {application.jar}
Note

It does not support Java 5 or earlier and IBM Java.

Starting the monitoring

Once the application server is restarted after configuring all settings, the agents start collecting data. See the following.