Consultor Eletrônico



Kbase 44758: How to generate a Java thread dump
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   22/06/2001
Solution ID: P14758

GOAL:

How to generate a Java stack dump from a SonicMQ process

FACT(s) (Environment):

SonicMQ

FIX:

To generate a stack dump for any Java process running on UNIX or
Linux, the process must be started with java.exe rather than jre.exe.
For the SonicMQ broker, this is set with the SONICMQ_JRE parameter in
<SonicMQ install dir>/bin/setenv. Make sure this points to the 'java'
executable rather than to 'jre', editing it if necessary.
If you do change this setting, you must shutdown the broker and
restart it for the change to take effect.

You must then obtain the process id of the Java process running the
broker. Using the ps -ef command, you'll see a process listed for
the startbr.sh script, which starts the broker. Its pid is the
parent process id (ppid) for the Java process running the broker.
Using the pid of this Java process, you can generate the stack dump
with the following command issued from a terminal or window
other than the one from which the broker or server was started:

kill -QUIT <pid>

On UNIX the output goes to the console; on Linux it is directed to a
text file whose name is displayed on the console.

To generate a stack dump for any Java process running on any Windows
platform, as above, the process must be started with java.exe, and it
must be started from the command line. (A stack dump cannot be
generated from a process running as a Windows service.) Then you can
generate the stack dump by hitting CTRL-BRK on the keyboard.

SonicMQ versions 3.5 and above install, and for the broker, use the
'java' executable by default on Windows, so no modifications to the
installed bat file are necessary.

For SonicMQ 2000.x and 3.0.x, the 'jre' executable is installed on
Windows, and is used by the SonicMQ broker by default. This means that
to get a stack dump from a pre-3.5 SonicMQ broker running on Windows
NT or Windows 2000, the variables used in startbr.bat to start the
broker must be modified. To get a stack dump from an administrative
client (Explorer or the command line admin tool), the same thing must
be done for explorer.bat or admin.bat. The same also applies to
SonicMQ.bat if you wish to get a stack dump while running any of the
SonicMQ samples.

So, for SonicMQ 2000.x and 3.0.x, you must do the following:

1. Install a JRE for your platform which includes the java executable;
the one installed automatically on NT under the SonicMQ install
directory includes only jre.exe.

2. Modify the SONICMQ_JRE and JRE_CLASSPATH variables. The original
settings are:

set SONICMQ_JRE=<SonicMQ install path>\java\bin\jre.exe
set JRE_CLASSPATH=<SonicMQ install path>\java\lib\rt.jar

They should be changed to:

set SONICMQ_JRE=<New JRE install path>\bin\java.exe
set JRE_CLASSPATH=<New JRE install path>\lib\rt.jar

3. Make sure the DOS command prompt window screen buffer size is as
large as you can set it, to accommodate the full output of the
thread dump.

For all versions of SonicMQ, you can now use your .bat file to start
the offending process, and hit CTRL-BRK when you wish to generate a
stack dump. The stack dump will appear in the console window.

NOTE: In all of the above cases, the JRE's JIT compiler is enabled by
default. For ongoing problems, it is often helpful to disable the JIT
compiler so that the stack traces generated will include line numbers
indicating each thread's path through the internal SonicMQ code.

The JIT compiler is typically disabled by passing an argument to the
JRE when a process is started; the argument and syntax varies by JRE
vendor and version.