简体   繁体   English

独立Java应用程序的线程转储

[英]thread dump of a stand-alone java app

I have a stand-alone java app running on linux + Java 6, which seems to be stuck (no logs being generated) How can i take thread dump of this, without using any other tool (eg. jstack) 我有一个在Linux + Java 6上运行的独立Java应用程序,该应用程序似乎卡住了(没有日志生成)如何在不使用任何其他工具(例如jstack)的情况下进行此线程转储

Tried below commands, but they are not doing anything 在下面的命令中尝试过,但是他们什么也没做

kill -3 <pid>
kill -QUIT <pid>

Am I missing anything ? 我有什么想念的吗?

You can use Java VisualVM (included in every JDK's bin directory) and connect through JMX. 您可以使用Java VisualVM(包含在每个JDK的bin目录中)并通过JMX连接。 Just add 只需添加

-Dcom.sun.management.jmxremote.port=PORT
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false

to your JVM startup parameters (at remote host) and enable authentication. (在远程主机上)到JVM启动参数并启用身份验证。

Then start VisualVM (at your client) and add a connection. 然后(在您的客户端上)启动VisualVM并添加连接。

See here: http://visualvm.java.net/docindex.html 参见此处: http : //visualvm.java.net/docindex.html

Get the pid from the jps command (although not necessary). jps命令获取pid(尽管不是必需的)。

Did you try with root privileges? 您尝试使用root特权吗? If the java process was initiated with root (or daemon) privileges you must take this into account. 如果Java进程是使用root(或daemon)特权启动的,则必须考虑到这一点。

# kill -3 <pid>
$ sudo kill -QUIT <pid>

You can also see the threads in the top output by pressing H (not h ). 您还可以通过按H (不是h )在top输出中查看线程。

Then if you identify the stuck you can grab the pid, make hexadecimal and then with the jstack see the stack trace. 然后,如果您确定卡住了,则可以获取pid,将其设置为十六进制,然后使用jstack查看堆栈跟踪。

Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM