Jstack Debugging in Windows 7

Dorado Software technical assistance sometimes uses the jstack stack trace tool to debug problems in Redcell. When you install application server to run as a service (autostart), the user SYSTEM owns the application server process. You also cannot log into Windows 7 as user SYSTEM. For security’s sake, no other user can access a service running as the SYSTEM user in later Windows 7 kernels. The jstack tool therefore does not work if you run it as the (non-SYSTEM) user logged in to Windows 7.

Workaround: To view a jstack output for application server, or any service (and its subprocesses) running as the user SYSTEM, you must run jstack (and jps) as user SYSTEM. Windows 7 provides no direct way to log in as user SYSTEM, so the following sidesteps this prohibition:

1. Open a command shell (Click the Start icon and type cmd in the Search Programs and Files field.)

2. At the command prompt, type:

sc create testsvc binpath= "cmd /K start" type= own type= interact

3. Then type:

sc start testsvc

The sc start command immediately creates a new command shell owned by SYSTEM, even if the original command window failed to start with error 1053 (this is expected since cmd.exe does not have any service-related code in it).

4. Open an oware shell inside the SYSTEM-owned command prompt created in Step 3. (Type oware at the command line.)

5. In that oware shell, run jps to see the process ID (PID) of the application server’s Java process (OWLaunchV2).

6. Then run jstack [PID] in the SYSTEM shell.

7. To delete the testsvc when you are finished, type this on a command line:

sc delete testsvc