J9 Java Dump Recipe
A J9 Java
Dump is a text file that includes a thread dump and other useful
information about a running Java process. A Java Dump is often called a
javacore because its name defaults to
javacore*.txt although javacores should not be confused
with operating system process core dumps (OS cores) which are large and
heavy.
In general, javacores have a low overhead and pause the proceess for less than a few hundred milliseconds, although there are pathological exceptions of ~20 second pauses that are potential risks to be aware of. In general, javacores are less than a few MB each although they can reach dozens of MBs if there are a lot of loaded classes.
- On non-Windows operating systems, unless default
-Xdump...events=usersettings have been changed, replace$PIDwith the process ID in the following (despite the signal name "QUIT", by default, unless-Xrsis specified, the JVM gracefully handles this signal and continues without quitting):kill -QUIT $PID - For Semeru Java, replace
$JAVA_HOMEwith the path to Java, and$PIDwith the process ID in (if running under a Windows Service, use a technique to run the command as the SYSTEM user):$JAVA_HOME/bin/jcmd $PID Dump.java - For IBM Java >= 8.0.6.25 that is a JDK, replace
$JAVA_HOMEwith the path to Java, and$PIDwith the process ID in (if running under a Windows Service, use a technique to run the command as the SYSTEM user):java -Xbootclasspath/a:$JAVA_HOME/lib/tools.jar openj9.tools.attach.diagnostics.tools.Jcmd $PID Dump.java - With WebSphere Application Server traditional:
- Administrative Console } Troubleshooting } Java dumps and cores } Check the server(s) } Java core
$WEBSPHERE/bin/wsadmin -lang jythonand the commandAdminControl.invoke(AdminControl.completeObjectName("type=JVM,process=$SERVER,*"), "dumpThreads")- On z/OS,
MODIFY $JOB,JAVACORE - On IBM i, use
WRKJVMJOB - Install the
twasdiagapplication and execute the/IBMJavaDumpservlet.
- With WebSphere Liberty:
- Using the
serverutility:$LIBERTY/bin/server javadump $SERVER - Install the
libertydiagapplication and execute the/servlet/ThreadDumpservlet.
- Using the
- For IBM Java >= 8.0.7.20 and IBM Semeru Runtimes >= 11.0.17.0
on non-Windows platforms, restart with:
Then request the javacore with:-Xdump:java:events=user2,request=exclusive+prepwalkkill -USR2 $PID - For IBM Java, use Java
Surgery:
java -jar surgery.jar -pid $PID -command JavaDump - Use code
within the JVM that executes
com.ibm.jvm.Dump.triggerDump("java:request=exclusive+prepwalk")using reflection - The IBM Java
javaDump Agent can take a javacore on various events. For example, the following will create a javacore when theExample.badmethod throws aNullPointerException:-Xdump:java:events=throw,range=1..1,request=exclusive+prepwalk,filter=java/lang/NullPointerException#com/ibm/example/Example.bad - The trace
engine may be used to request a javacore on method entry and/or
exit. The following example JVM argument produces a javacore when the
Example.trigger()method is called:-Xtrace:maximal=mt,trigger=method{com/ibm/example/Example.trigger,javadump,,,1} - On Windows, if a Java process is started connected to a Command
Prompt, then you may use
Ctrl+Break.