java 如何远程调试运行在tomcat服务上的webapplication?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10221429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 00:06:22  来源:igfitidea点击:

How to remotely debug the webapplication running on tomcat service?

javatomcat6

提问by M Sach

I have my webapplication on tomcat 6at serverA. I am running the tomcatas service i.e thru tomcat6w.exelying under <tomcat_home>/binfolder. To remotely debug the weabbplication i have added below lines as suggested on different blog/sites on web in different line witout space at end. Mentioned the port as 8443 as application is running on same port.

我在 serverA 上有我的 web 应用tomcat 6程序。我正在运行tomcat作为服务,即通过tomcat6w.exe位于<tomcat_home>/bin文件夹下。为了远程调试 web 应用程序,我在网络上的不同博客/网站上的建议下添加了以下行,最后一行没有空格。提到端口为 8443,因为应用程序在同一端口上运行。

-Xdebug-Xrunjdwp:transport=dt_socket,address=8443,server=y,suspend=n

Now thru eclipseon server B i mentioned host as serverA and port 8443 and click debug. After 2-3 minutes it establishes connection without giving any error.But now when i hit webapplication url in IEit does not show up and says IEcan not display the webpage. But as soon as i remove the above mentioned debug parameters and hit the url, application works fine. I am not getting how should i debug the application when tomcat is running as window service?

现在通过eclipse服务器 B 我提到主机作为 serverA 和端口 8443 并单击调试。2-3 分钟后,它建立连接而没有给出任何错误。但是现在当我点击 webapplication url 时,IE它没有显示并说IE无法显示网页。但是一旦我删除了上面提到的调试参数并点击了 url,应用程序就可以正常工作。当 tomcat 作为窗口服务运行时,我不知道应该如何调试应用程序?

For Information Below are the parameters when i double click the tomcat service

以下是我双击tomcat服务时的参数

--   Under java tab 
--jvm section value  
 C:\Program Files\Java\jre6\bin\client\jvm.dll

--java classpath section value  
 C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\bootstrap.jar

--java options section value  
 -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 6.0
 -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 6.0
 -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 6.0\common endorsed
 -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 6.0\temp
 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
 -Djava.util.logging.config.file=C:\Program Files\Apache Software 
  Foundation\Tomcat6.0\conf\logging.properties-XX:MaxPermSize=512M
 -Djavax.net.ssl.trustStore=c:/.keystore
 -Djavax.net.ssl.trustStorePassword=changeit-Xdebug 
 -Xrunjdwp:transport=dt_socket,address=8443,server=y,suspend=n  

--Under startup tab

--class section value  
org.apache.catalina.startup.Bootstrap

--workingpath section value  
 C:\Program Files\Apache Software Foundation\Tomcat 6.0

--arguments section value  
 start

--mode section value  
 jvm

回答by abhdeb

In the Java Options tab add the below. Remember to put

在 Java 选项选项卡中添加以下内容。记得放

-Xdebug 

and

-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8733

in SEPARATE LINE.

单独的行中

-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8733

回答by Felix

you can pass JVM options using JvmOptionsparameter:

您可以使用JvmOptions参数传递 JVM 选项:

tomcat.exe //TS// ++JvmOptions -Xdebug;-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

or

或者

tomcat.exe //RS// ++JvmOptions -Xdebug;-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

回答by kyiu

When I need to remotely debug an application that is deployed on Tomcat, I usually start the server through the Catalina.bat script, not as a Windows service. Actually, to enable remote debugging, you're supposed to provide the JPDA arguments when executing the catalina.bat script :

当我需要远程调试部署在 Tomcat 上的应用程序时,我通常通过 Catalina.bat 脚本启动服务器,而不是作为 Windows 服务。实际上,要启用远程调试,您应该在执行 catalina.bat 脚本时提供 JPDA 参数:

catalina jpda start

卡特琳娜 jpda 开始

If you really need to start your server as a service, you could try to edit its definition so that you also provide the JPDA argument to it.

如果您确实需要将您的服务器作为服务启动,您可以尝试编辑它的定义,以便您也向它提供 JPDA 参数。

Yo could as well stop your Tomcat service and just start the server by executing the catalina.bat script.

你也可以停止你的 Tomcat 服务,然后通过执行 catalina.bat 脚本来启动服务器。

Hope that'll help.

希望这会有所帮助。