Can't debug Java Windows Services with jhat, jps, jstack
- by Matthew McCullough
I frequently showcase the jhat, jps, and jstack tool set to developers on Linux and Mac. However, a developer recently indicated that these are unusable in Windows if the Java app in question is running as a Windows Service.
A Sun-filed bug says something very similar, but was closed due to inactivity.
I have tested this out for myself, and indeed it appears true, though I can hardly believe it. Here is the setup:
Tomcat or similar running as a Windows service with the "Log On As" == "Local System"
A user with Admin privileges logged in to the same Windows machine.
Admin opens Windows Task Manager, can see java.exe running
Admin opens console, types "jps", gets back a list of processes that does not include Tomcat's java service process.
As a brute force attempt, get the PID of tomcat as a service from Windows Task Manager. Type jstack < pid . Get a reply: < pid no such process
This appears reproducible under Windows XP, Windows 2003 Server, and Windows 7. Java versions 1.5 and 1.6 yield the same outcome.
Is there a way from the terminal, even though logged in as Admin, to "sudo up" to get JPS and the other tools to see the java service?