无法将JCSsole与作为Windows服务运行的Tomcat一起使用
我正在运行tomcat 6.0.18作为Windows服务。 在服务小程序中,jvm配置为默认值,即它使用JRE的jvm.dll。
我试图用JConsole监视此应用程序,但无法在本地连接到它。 我添加了参数-Dcom.sun.management.jmxremote(在使用start.bat脚本启动tomcat时有效)。 但是jvm似乎没有拿起参数。
有一个很好的GUI来编辑选项,不需要在注册表中捣乱。
打开C:\ Program Files \ Apache Software Foundation \ Tomcat 6.0 \ bin \ tomcat6.exe(或者只需双击任务栏中的监视器图标)。 转到Java窗格,将以下内容添加到参数列表中,然后重新启动Tomcat。
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port = 8086 -Dcom.sun.management.jmxremote.ssl = FALSE -Dcom.sun.management.jmxremote.authenticate = FALSE
然后,您可以连接JConsole或更新的VisualVM。
这是更改jvmoptions并与服务交互的规定方式:
http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html
我会尝试进入您的注册表HKLM / Software / Apache Software Foundation / Procrun 2.0 //参数/ Java并直接编辑“Options”多字符串值。
我发布它主要是为了记录这些信息给我自己,我还没有validation它 – 但这应该也有效:
http://mysqlandsqlserver.blogspot.com/2010/02/jconsolejmap-and-tomcat-as-windows.html
还有一种相当简单的方法可以将JConsole连接到使用我在此处发现的本地模式作为Windows服务启动的Java进程。
基本上它表示为了连接到作为Windows服务启动的Java进程,您需要将JConsole作为Windows服务启动(您可以使用Windows native api或使用任何包装器,如yajsw) 。
顺便说一句,这将使您无需重新启动对我来说至关重要的Java Process。
如果Tomcat作为Windows服务运行,并且您希望在本地附加到JVM,则需要将VisualVM或JConsole作为系统帐户运行。 您可以使用Sysinternals PsExec.exe来完成此任务。
psexec.exe -i -sc:\visualvm\bin\visualvm.exe
在catalina.bat顶部附近添加以下内容
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote ^ -Dcom.sun.management.jmxremote.port=8086 ^ -Dcom.sun.management.jmxremote.ssl=false ^ -Dcom.sun.management.jmxremote.authenticate=false
停止并重新启动tomcat(显然)
运行jconsole.exe。 如果您的tomcat作为服务运行,则以管理员身份运行jconsole.exe。
选择Remote Process并输入localhost:8086