我可以将Tomcat作为转储堆的服务运行吗? [英] Can I get Tomcat running as a service to dump heap?

查看:112
本文介绍了我可以将Tomcat作为转储堆的服务运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让Tomcat(当前在Windows 2003机器上作为服务运行)在 OutOfMemoryError 上转储堆。

I am attempting to have Tomcat, which is currently running as a service on a Windows 2003 box, dump heap on an OutOfMemoryError.

(Tomcat正在运行Hudson,它在我的构建的尾端报告堆空间问题。手动运行构建不会产生这样的错误.Hudson家伙需要堆转储才能开始。)

(Tomcat is running Hudson, which is reporting a heap space problem at the tail end of my build. Running the build manually produces no such error. The Hudson guys need a heap dump to get started.)

正如其他地方所说,我已经告诉Apache Service Monitor配置它用来运行Tomcat以在 OutOfMemoryError
-XX:+ HeapDumpOnOutOfMemoryError
然后我再次运行构建。果然,它报告存在堆错误。我扫描整个磁盘,寻找默认的 java_pid123.hprof 文件(显然 123 被替换为PID JVM)。没有 .hprof 文件存在于任何地方。

As instructed elsewhere, I've told the Apache Service Monitor to configure the JVM it uses to run Tomcat to dump heap when an OutOfMemoryError is encountered by adding the following to the JVM options: -XX:+HeapDumpOnOutOfMemoryError Then I run the build again. Sure enough, it reports there was a heap error. I scan the entire disk looking for the default java_pid123.hprof file (where obviously 123 is replaced by the PID of the JVM). No .hprof files exist anywhere.

我陷入困境22:我需要堆转储哈德森家伙修复他们的内存泄漏,但如果我在Tomcat下运行Hudson,我就无法获得堆转储。

I am caught in a catch 22: I need the heap dump for the Hudson guys to fix their memory leak, but I can't get the heap dump if I run Hudson under Tomcat.

当Tomcat运行时,是否有一些特殊方式一个Windows服务,从OutOfMemoryError上获取堆转储?

Is there some special way, when Tomcat is running as a Windows service, to get a heap dump from it on an OutOfMemoryError?

我试过的另一件事就是在Startup和Shutdown标签上告诉它使用Java选项而不是jvm选项。我相信这应该告诉Service Manager尝试使用Java可执行命令启动Tomcat,而不是直接启动 jvm.dll 。当我这样做时,服务将无法启动。

The other thing I've tried is to tell it, on the Startup and Shutdown tabs, to use the "Java" option instead of the "jvm" option. I believe this should tell the Service Manager to attempt to start Tomcat with a Java executable command instead of launching the jvm.dll directly. When I do this, the service won't start.

肯定有其他人遇到类似的问题?

Surely someone else has had a similar problem?

推荐答案

最后把这个放到床上后,我想对可能遇到同样问题的其他人回答这个问题。

After finally putting this one to bed, I wanted to answer this for others who might have the same problem.

首先,如果您在Windows上安装Tomcat,请不要使用 .exe 安装程序,即使它是由Apache提升的。无论你做什么,它都不会让你将Tomcat作为系统帐户以外的任何东西运行。看起来系统帐户没有在当前目录中写入 .hprof 文件的权限,并且没有任何Windows安全性调整可能会导致此问题消失。

First, if you install Tomcat on Windows, do not use the .exe installer, even though it is promoted by Apache. It will not let you run Tomcat as anything other than the system account, no matter what you do. It appears that the system account does not have privileges to write .hprof files in the current directory, and no amount of Windows security tweaking appears to make this problem go away.

好的,所以你已经从 .zip 发行版中安装了Tomcat。使用 service.bat 脚本将其安装为服务。确保将其设置为以专门为此目的创建的特定用户身份运行。确保在用户可以写入堆转储时希望Tomcat写入的文件夹。

OK, so you've installed Tomcat from the .zip distribution. Install it as a service using the service.bat script. Make sure it is set to run as a specific user that you created specifically for this purpose. Make sure as well that the folder you want Tomcat to write to in the event of a heap dump is writable by that user.

编辑服务.bat 文件包含 -XX:+ HeapDumpOnOutOfMemoryError -XX:HeapDumpPath = C:\whatever 选项位于正确的位置(可以放置JVM选项)。这应该可以解决问题。

Edit the service.bat file to include the -XX:+HeapDumpOnOutOfMemoryError and the -XX:HeapDumpPath=C:\whatever options in the correct place (where you can put JVM options). That should do the trick.

这篇关于我可以将Tomcat作为转储堆的服务运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆