|
|
Sacha Mallais
|
|||||||||||
|
|
|
|
|||||||||
| Navigate Database Table: "WOFAQ" | ||||||||||
| Current record is #1 out of 21 in found set (21 total records in table) | ||||||||||
|
|
|||||||||
| Question | How do I get a stack trace / thread dump from a running java application? |
|---|---|
| Answer |
The short answer is: send the process the QUIT signal, or, under Java 1.5, use the jstack command. The long answer: Under Java 1.4, you first need to make sure that the thread dump goes someplace useful. Doing this requires changing the WO startup script -- called SpawnOfWotaskd.sh -- changing SpawnOfWotaskd.sh is generally a good idea even for Java 1.5, as it also helps in other situations, like when an app doesn't start properly. If you're using Java 1.5 or you started the application from the command line, then skip to step 2. If you started the app automatically with JavaMonitor (which configures wotaskd to actually start the app), then you'll need to do some extra configuration.
Step 1: Edit wotaskd's App Launch Script sudo emacs /System/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/SpawnOfWotaskd.sh Next, change the contents from this:
#!/bin/sh
To this:
#!/bin/sh
Now restart the instance from JavaMonitor. Step 2: find the process ID If you started the app from JavaMonitor, log into JavaMonitor and click the "Detail" button of the application you are interested in. This will list all running instances of the application. Note down the port number of the instance whose process ID is required. If you started the app from the command line, use the -WOPort argument to start up on a known port, or examine the log output to determine the dynamically assigned port. In terminal on the server (or via ssh from your local machine) enter the following command: ps -auxwww | grep <port number>This will produce output as follows:
Step 3: Send the QUIT Signal This works on JDK 1.4 and later (and maybe earlier): kill -QUIT <pid> e.g. kill -QUIT 22869 The output will be:
OR Step 3: Run jstack (Java 1.5 and later) sudo jstack <process id>Recent versions (at least on Leopard) of jstack do not show the correct thread names. You may find the kill -QUIT results more useful. |
| Figure 1 | No file available. |
| Figure 2 | No file available. |
| Figure 3 | No file available. |
| Date Modified | Aug 7 2009 |
| Modified By | chill@global-village.net |