java jstack tool insufficient memory or insufficient privilege to attach
Asked Answered
L

1

7

I am really confused about: In my windows 2008r2, I have a windows service, in fact it's a java progress running as SYSTEM user. Now, I use Jstack rawly to the the service. But it occur error :

 insufficient memory or insufficient privilege to attach

But if I use Jstack's options -F , it can work finely. I view the jdk's source, It uses a class BugSpotAgent to finish above.

I want to know the root cause I can't use Jstack rawly, is it the SYSTEM user privilege problem? I also have try to use PsExec.exe(a tool) to run my Jstack rawly(That means I will use SYSTEM user to run Jstack), but it still can't work.

Can you help me?

Thanks & Regards!

Linder answered 22/11, 2013 at 16:23 Comment(1)
See also Jstack and Not enough storage is available to process this command for workaround for windows services.Biotype
G
5

jstack can only latch on to a process started by Same User in Same Session. When a session is not specified the psexec command latches on to console session and throws this error while trying to get thread dump.

The solution is to ensure the user and session used with psexec is the same as one used for target java process.

if it has been started by a regular user, a. use the same user credentials to login without -s or -h flag b. find the session ID in which the process was started. (You can find it using Task Manager and going to the Tab Users). Use this session id with the flag -i

psexec \\server-name -u username -p password -i session-id command

e.g.

psexec \\192.168.1.1 -u john -p pass123 -i 1 jstack.exe 4242

Note: If the java process has been started by a SYSTEM user use the flag -s

Glori answered 16/7, 2014 at 15:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.