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.

  1. On non-Windows operating systems, unless default -Xdump...events=user settings have been changed, replace $PID with the process ID in the following (despite the signal name "QUIT", by default, unless -Xrs is specified, the JVM gracefully handles this signal and continues without quitting):
    kill -QUIT $PID
  2. For Semeru Java, replace $JAVA_HOME with the path to Java, and $PID with 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
  3. For IBM Java >= 8.0.6.25 that is a JDK, replace $JAVA_HOME with the path to Java, and $PID with 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
  4. With WebSphere Application Server traditional:
    1. Administrative Console } Troubleshooting } Java dumps and cores } Check the server(s) } Java core
    2. $WEBSPHERE/bin/wsadmin -lang jython and the command AdminControl.invoke(AdminControl.completeObjectName("type=JVM,process=$SERVER,*"), "dumpThreads")
    3. On z/OS, MODIFY $JOB,JAVACORE
    4. On IBM i, use WRKJVMJOB
    5. Install the twasdiag application and execute the /IBMJavaDump servlet.
  5. With WebSphere Liberty:
    1. Using the server utility:
      $LIBERTY/bin/server javadump $SERVER
    2. Install the libertydiag application and execute the /servlet/ThreadDump servlet.
  6. For IBM Java >= 8.0.7.20 and IBM Semeru Runtimes >= 11.0.17.0 on non-Windows platforms, restart with:
    -Xdump:java:events=user2,request=exclusive+prepwalk
    Then request the javacore with:
    kill -USR2 $PID
  7. For IBM Java, use Java Surgery:
    java -jar surgery.jar -pid $PID -command JavaDump
  8. Use code within the JVM that executes com.ibm.jvm.Dump.triggerDump("java:request=exclusive+prepwalk") using reflection
  9. The IBM Java java Dump Agent can take a javacore on various events. For example, the following will create a javacore when the Example.bad method throws a NullPointerException:
    -Xdump:java:events=throw,range=1..1,request=exclusive+prepwalk,filter=java/lang/NullPointerException#com/ibm/example/Example.bad
  10. 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}