WebSphere Application Server Java Dumps

This article is meant to bring you up to speed on Java dumps and their debugging purposes quickly. It assumes that you’re familiar with basic Java, the Java Virtual Machine (JVM), and threading concepts. Some information about Java dumps and their contents is intentionally omitted from the discussion to simplify things since it’s not relevant to the type of problem determination discussed here.

Basics
A Java dump, also known as a Java core, Java thread dump, or a thread dump is a file that contains the following sections:
In this article we’ll refer to this collection of threads, monitors, and miscellaneous information as a Java dump. We’ll focus mainly on the Java dumps from the IBM Java Development Kit (JDK) 1.3.1 and JDK 1.4.1. Although the formats of Java dumps can vary slightly with the different versions of the JDK depending on the vendor and platforms, you’ll be able to apply most of the concepts discussed here in interpreting Java dumps from WebSphere Application Server V4.x, V5.0.x, and V5.1.x.

Format – Dump Routines
The following picture is a representation of a Java dump broken into subcomponents:

The following list describes the subcomponents found in Figure 1:

Operating System Differences
Java dumps vary from one operating system to another. Although the variation doesn’t differ greatly, most of the differences are found in the operating-specific information that the Java dump routines collect. One of these differences is how the environment variables that are set on a specific operating system in a Unix system, for example, are handled differently than Windows environment variables. These variables will display differently when you collect a Java dump on a Unix system and compare it to one collected on a Windows system.

Java Service Release Differences
Between each Java service release, the Java dump routine is enhanced to provide the most information possible when diagnosing problems.
For this reason, you’ll notice that a Java dump from one service release of the JDK to another is formatted differently in terms of tabs or spaces or additional information. For example, if you compare JDK 1.2.x Java dumps to JDK 1.3.x Java dumps, you’ll notice that the structure of the two documents is very different. Some data that’s found on the JDK 1.2.x Java dump is rearranged in the JDK 1.3.x Java dumps, such as the XM dump and LK dump routine locations.

Java Dump – Thread & Monitor Analysis
The following is an example of a thread stack trace in the XM dump routine:
3XMTHREADINFO “Thread-6” (TID:0x181D6A0, sys_thread_
  t:0x133AA648, state:R, native ID:0x948) prio=5
4XESTACKTRACE at java.net.PlainSocketImpl.
  socketAccept(Native Method)
4XESTACKTRACE at java.net.PlainSocketImpl.
  accept(PlainSocketImpl.java:446)
4XESTACKTRACE at java.net.ServerSocket.
  implAccept(ServerSocket.java:264)
4XESTACKTRACE at java.net.ServerSocket.
  accept(ServerSocket.java:243)
4XESTACKTRACE at com.ibm.disthub.impl.multi.server.
  SSConnMgr.threadMain(SSConnMgr.java:251)
4XESTACKTRACE at com.ibm.disthub.impl.client.
  DebugThread.run(DebugThread.java:66)
Example 1 – This is an example of a Java thread’s stack trace in the XM Dump Routine The first line of the previous example indicates that there’s a thread named Thread-6 that’s in a runnable state as indicated by the “state:R” parameter. This means that Thread-6 is either running or ready to run. Like all threads, Thread-6 has two primary identifiers: TID and sys_thread_t. For Thread-6, the values include 0x181D6A0 and 0x133AA648 respectively. You can cross-reference these values with the monitor data in the LK dump routine to detect deadlocks and identify problematic threads.

The remaining lines of text, identified by the “4XESTACKTRACE” tag, indicate the sequence of methods performed by the thread when the Java dump occurred. It is like a standard Java stack trace where the beginning of the code execution is read from the bottom to the top.

Just In Time (JIT) compiling is enabled when line numbers are replaced by the keywords “Compiled Code” in a stack trace as shown in Example 2. Disable JIT compiling to display the line numbers. Refer to the WebSphere Application Server InfoCenter for instructions on disabling JIT compiling in a WebSphere Application Server environment at http://www.ibm.com/software/webservers/appserv/infocenter.html.

Disabling JIT compiling can affect the performance of the JVM significantly especially during periods of high load.
4XESTACKTRACE at com.ibm.ws.util.BoundedBuffer.
  take(BoundedBuffer.java(Inlined Compiled Code))
4XESTACKTRACE at com.ibm.ws.util.ThreadPool.
  getTask(ThreadPool.java(Compiled Code))

Example 2 – You can see the Compiled Code and Inlined Compiled Code references where the line number in a typical stack trace is observed. Threads have states, as shown in Example 1. Most threads will indicate either an R or a CW state. The following is a list of states and a brief description of each:

Looking into Monitors – LK Dump Routine
The following table shows how the LK Dump routine is broken down into five subsections:


Looking into Classloaders – CL Dump Routine
The CL dump routine shows the list of class loaders and their corresponding classes. The respective address for each class and class loader is also shown in this section of the Java dump. The type for each class loader is shown to the left of the name of the class loader indicating if the class loader is primordial, extension, shareable, middleware, system, or trusted.

WebSphere Application Server Java Dumps
There are several types of threads that appear when you generate a Java dump in a WebSphere Application Server. The following list contains the types of threads that reside in most WebSphere Application Server Java dumps:
3XMTHREADINFO “ServerSocket[addr=0.0.0.0/
  0.0.0.0,port=0,localport=9085]” (TID:0x10628F00,
sys_thread_t:0x4D87A80, state:R, native ID:0x9C4) 
  prio=5
4XESTACKTRACE at java.net.PlainSocketImpl.
  socketAccept(Native Method)
4XESTACKTRACE at java.net.PlainSocketImpl.
  accept(PlainSocketImpl.java(Compiled Code))
4XESTACKTRACE at java.net.ServerSocket.
  implAccept(ServerSocket.java(Compiled Code))
4XESTACKTRACE at java.net.ServerSocket.
  accept(ServerSocket.java(Compiled Code))
4XESTACKTRACE at com.ibm.ws.http.HttpTransport.
  run(HttpTransport.java:235)
4XESTACKTRACE at java.lang.Thread.run(Thread.java:568)
Example 3 – This example shows the Server Socket thread listening to port 9085 on an IBM V1.4.1 JVM and accepting a connection.
3XMTHREADINFO “Servlet.Engine.Transports : 0” 
  (TID:0x10631CC8, sys_thread_t:0x4E397A8, state:R,
native ID:0xEF4) prio=5
4XESTACKTRACE at java.net.SocketInputStream.
  socketRead0(Native Method)
4XESTACKTRACE at java.net.SocketInputStream.
  read(SocketInputStream.java(Compiled Code))
4XESTACKTRACE at com.ibm.ws.io.Stream.read(Stream.
  java:17)
4XESTACKTRACE at com.ibm.ws.io.ReadStream.
  readBuffer(ReadStream.java(Compiled Code))
4XESTACKTRACE at com.ibm.ws.io.ReadStream.
  read(ReadStream.java(Compiled Code))
4XESTACKTRACE at com.ibm.ws.http.HttpRequest.
  readRequestLine(HttpRequest.java(Compiled Code))
4XESTACKTRACE at com.ibm.ws.http.HttpRequest.
  readRequest(HttpRequest.java:302)
4XESTACKTRACE at com.ibm.ws.http.HttpConnection.
  readAndHandleRequest(HttpConnection.java:596)
4XESTACKTRACE at com.ibm.ws.http.HttpConnection.
  run(HttpConnection.java:443)
4XESTACKTRACE at com.ibm.ws.util.ThreadPool$Worker.
  run(ThreadPool.java(Compiled Code))

Example 4 – This example represents the Servlet Engine Transport thread reading the request from the socket provided by the server socket thread.
3XMTHREADINFO “ORB.thread.pool:14118” (TID:0x10B1B7B0,
  sys_thread_t:0x45F9BCE0, state:CW, native
ID:0x1624) prio=5
4XESTACKTRACE at java.lang.String.valueOf(String.
  java(Compiled Code))
4XESTACKTRACE at com.trade.eps...getNextInBatch
  (TopCrateFactory.java:99)
4XESTACKTRACE at com.trade.eps...getNextInBatch
  (TopSequenceGenerator.java:259)
4XESTACKTRACE at com.trade.eps...getNextInSequence
  (TopLinkGenerator.java:220)
4XESTACKTRACE at com.trade.eps...setKeyAttributes
  (TopTxnnManager.java:1138)
...
4XESTACKTRACE at com.ibm.CORBA.iiop.ORB.process
  (ORB.java(Compiled Code))
4XESTACKTRACE at com.ibm.CORBA.iiop.OrbWorker.
  run(OrbWorker.java(Compiled Code))
4XESTACKTRACE at com.ibm.ejs.oa.pool.
ThreadPool$PooledWorker.run(ThreadPool.java
  (Compiled Code))
4XESTACKTRACE at com.ibm.ws.util.CachedThread.
  run(ThreadPool.java(Compiled Code))
Example 5 – This example represents the server ORB thread executing an Enterprise Bean.

Initiating Java Dumps on WebSphere Application Server 5.x
You can initiate the WebSphere Application Server Java dumps using the wsadmin tool just follow these steps:
  1. Start the wsadmin tool in the WebSphere/AppServer/bin/wsadmin.sh (or .bat on Windows).
  2. Get a handle on the JVM process for which you want to initiate a dump. Typically this is the WebSphere Application Server process set by default to server1.
  3. Invoke the dumpThreads method using the AdminControl object. The following example demonstrates the code used to do this for a default server1 process once you invoke the wsadmin tool. See the WebSphere Application Server InfoCenter for more information.
wsadmin>set jvm [$AdminControl completeObjectName 
  type=JVM,process=server1,*]
WebSphere:platform=common,cell=merengue51BaseNode,
  version=5.0.1,name=JVM,mbeanIdentifier=JVM,type=JVM,n
ode=merengue51BaseNode,process=server1
wsadmin>$AdminControl invoke $jvm dumpThreads

Example 6 – This example demonstrates invoking a Java dump using the wsadmin tool. By default these files are generated in the WebSphere/AppServer/ directory. However, you can specify the location using an environment variable supplied to the JDK. For more details on this environment variable, invoking Java dumps using operating system-specific signals, and other options for invoking Java dumps, see the IBM JVM Diagnostics Guides in the reference section of this article.

Types of Problems Detectable by a Java Dump
The following list includes problem indicators in a Java dump. For many of these problems you can use ThreadAnalyzer to detect and determine the cause:
  1. Determine which thread owns the monitor that’s creating the bottleneck by looking at the LK dump routine and singling out the monitor that seems to have the longest (abnormal) list of threads waiting on it. You can identify by the number of threads that follow the text “Waiting to be notified.”
  2. View the XM subcomponent dump routine for the details of the thread that owns the monitor (the one with the large number of waiting threads) by comparing the thread identification (provided in the LK dump routine) with the XM dump routine.
  3. Determine the state of the thread and do one of the following:

Classloader Problems
If the application experiences problems or errors related to Java classes missing at runtime, determine which class file is missing by looking at the classes that are loaded by the class loader and listed under the CL subcomponent dump routine. If you can’t find the class that’s in the CL subcomponent dump routine, make sure you can find the class in the file system under the appropriate structure. Otherwise, make sure that the class file is being loaded by the proper class loader. For further information, go to the WebSphere Application Server InfoCenter or the references listed below.

ThreadAnalyzer
ThreadAnalyzer is a problem determination tool for WebSphere Application Server thread performance and deadlock detection. You can use it to obtain a Java dump from an application server and use its analysis features for problem determination. For performance problem determination, ThreadAnalyzer provides a top-of-the-stack (TOS) analysis that counts all of the methods at the top of the stack for the listed threads. It then sorts them by ‘weight’ (automatically computed by ThreadAnalyzer), and lists the possible performance bottlenecks in your application. ThreadAnalyzer does automatic deadlock detection while it analyzes the Java dump.

Downloading ThreadAnalyzer
To download ThreadAnalyzer:
  1. Go to http://www.ibm.com/developerworks/websphere/downloads/thread_analyzer.html
  2. Follow the links to the login. If you don’t have an account, click the “I have not registered before” link.
  3. Follow the rest of the links to download ThreadAnalyzer.
Basic Use of ThreadAnalyzer
To install ThreadAnalyzer, extract the contents of the zip file to anywhere in your file system. To start ThreadAnalyzer make sure you have WebSphere Application Server V4 or V5 installed and then start the tagui.cmd or tagui.sh file located in the <ThreadAnalyzerInstall>/bin directory. For more information on ThreadAnalyzer, see the product documentation provided in the zip file on installation.

References
Acknowledgements
    Many thanks for the contributions provided by Steve Eaton, Daniel Julin, and Arvind Srinivasan. 

© 2008 SYS-CON Media