Windows 服务应用程序上的 Java5 - 获取完整线程转储需要澄清

发布于 2024-09-17 01:14:15 字数 783 浏览 3 评论 0原文

我在这里浏览了几篇文章,例如:

Windows 上的 Java 堆栈转储

< a href="https://stackoverflow.com/questions/239544/thread-dump-programmatically-jdi-java-debugger-interface">以编程方式进行线程转储/JDI(Java 调试器接口) 但没有得到确切的答案。

问题: Windows 上有一个作为服务运行的 Java5 应用程序(因此我们没有可以使用 Ctrl+Break 进行转储的控制台)。 有时应用程序会挂起,我们需要线程转储。

我们尝试过“jstack”,但它在我们的环境中不起作用(我们发现它仅兼容Java6)。

因此,我们制作了一个 C++ 应用程序,通过附加到 Java 应用程序进程的 .dll 调用方法来调用线程转储,因此它需要本地管理员权限,这不太好。

因此,我们希望有其他选项无需管理员权限即可使用,并且可与 Java 5 一起使用,而无需对现有代码进行大量返工。

在循环线程转储中进行打印的方法 (Thread.getAllStackTraces()) 不是一个选项,因为我们需要重构大量应用程序才能使其工作。

因此,从应用程序“外部”工作的实用程序将是最好的选择。

提前致谢!

I've looked through couple of articles here such as:

java stack dump on windows

Thread dump programmatically /JDI (Java Debugger Interface)
But didnt catch the exact answer.

The problem:
There is a Java5 Application on Windows that's runs as a service (so we dont have a console where we are able to use Ctrl+Break for Dumping).
And sometimes Application hangs and we need a thread dump.

We've tried "jstack" but it doesnt work in our env (we found out that its Java6 only compatible).

So we made a C++ app that calls thread dump via .dll call method attaching to the Java app process, and because of this it needs Local Admin rights, that is not so good.

So we'd like other options that works without admin rights and works with Java 5 without lots of rework of existing code.

Method with Printing in LOOP thread dumps (Thread.getAllStackTraces()) is not an option because we need to refactor lots of applications in order to make it work.

So that just an util that works from "outside" of applications would be a best option.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铁憨憨 2024-09-24 01:14:15

一种选择是使用 jmap 转储所有信息,然后使用其他工具对其进行分析。

jmap -dump:format=b,file=<filename>.hprof <jvm_pid>

我不确定,购买我认为它可以在 Java 5 上工作。

参考文献:

One option is to dump all the information using jmap, and then analyzing it using other tool.

jmap -dump:format=b,file=<filename>.hprof <jvm_pid>

I am not sure, buy I think it will work on Java 5.

References:

哽咽笑 2024-09-24 01:14:15

您可以使用 JConsole 附加到进程来检测死锁并获取线程的堆栈跟踪。有关详细信息,请参阅此处: http://java.sun.com/developer /technicalArticles/J2SE/jconsole.html

You can attach to the process with JConsole to detect deadlocks and get stack traces of the threads. For more information, see here: http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文