Skip to main content

Tomcat

Adding the boot environment

This guide explains how to add required Tomcat options to effectively use the Java monitoring agent in the WebLogic application server environment. Set it according to the operating system.

Linux

At the top of the catalina.sh file, add the JAVA_OPTS environment variable.

{Tomcat_PATH}/bin/catalina.sh
########## WHATAP START ############
WHATAP_HOME=/whatap
WHATAP_JAR=`ls ${WHATAP_HOME}/whatap.agent-*.jar | sort -V | tail -1`
JAVA_OPTS="${JAVA_OPTS} -javaagent:${WHATAP_JAR} "
########## WHATAP END ############
Note

The ls ${WHATAP_HOME}/whatap.agent-*.jar | sort -V | tail -1 entry is used to apply the latest WhaTap agent for future update.

Windows

  • In case of running the setup.bat file

    At the top of the catalina.bat file, add the JAVA_OPT environment variable.

    {Tomcat_PATH}/bin/catalina.bat
    rem ########## WHATAP START ############
    set WHATAP_HOME=C:\whatap
    for /f %%f in ('dir /b /on "%WHATAP_HOME%\whatap.agent-*.jar"') do set last=%%f
    set WHATAP_JAR=%last%
    set WHATAP_OPTS=-javaagent:%WHATAP_HOME%\%WHATAP_JAR%

    if "x%JAVA_OPTS%"=="x" goto setWhatap

    set JAVA_OPTS_TMP=%JAVA_OPTS:"=%
    if not "x%JAVA_OPTS_TMP:whatap=%"=="x%JAVA_OPTS_TMP%" goto endWhatap

    :setWhatap
    set JAVA_OPTS=%JAVA_OPTS% %WHATAP_OPTS%

    :endWhatap
    rem ########## WHATAP END ############
  • In case tomcat has been installed with the Windows installer

    1. Select Start > Apache Tomcat X.Y.Z. > Configure Tomcat.

    2. Select the Java tab.

    3. Add the -javaagent option to the Java Options field.

    -javaagent:{WhaTap installation path}/whatap.agent-X.Y.Z.jar

    Apache Tomcat

Java 17 or later

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.