使用IntelliJ远程调试Tomcat 7

时间:2016-09-26 12:52:27

标签: java tomcat intellij-idea remote-debugging

我在 10.0.1.62:8080/xxx 上运行了一个Web应用程序。我想通过IntelliJ IDEA远程调试。我已设置 JAVA_OPTS = -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

在10.0.1.62机器上(在Ubuntu上为Tomcat7),当我点击远程调试按钮时,IDE正在给出一条信息消息:

  

连接到目标虚拟机,地址:'10 .0.1.62:8000',传输:'socket'

我正在点击 10.0.1.62:8080/xxx 。 虽然我得到了这个成功的消息,但brekpoints却没有被击中。我错过了什么?

1 个答案:

答案 0 :(得分:3)

首先,请参阅此问题并仔细检查您的设置:Remote Debugging in IntelliJ Tomcat

从你的问题来看,听起来你已经按照这些步骤进行了操作。还有一些其他的配置问题导致我在过去的远程tomcat调试问题,我将分享并希望它有所帮助。

  1. 确保在IntelliJ上启动了正确的远程调试过程。 Remote Debug
  2. 如果主机上运行多个Tomcat服务器,请确保连接到正确的Tomcat实例。调试端口8000可能已在使用中。我使用15019的任意端口或其他尚未使用的端口号。确保使用的端口在Tomcat和IntelliJ之间匹配。
  3. 根据您在Tomcat上设置远程调试的方式,它可能无法正常关闭,而旧的实例正在运行。在catalina.sh顶部添加调试挂钩将导致shutdown.sh脚本失败,因为您的调试端口已绑定到Tomcat服务器。而是将它放在start if语句中:

    elif [ "$1" = "start" ] ; then JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=15019,suspend=n,server=y"

  4. 修复此问题后,您可以使用./shutdown.sh成功关闭Tomcat,并仍然可以使用./startup.sh启动调试

    1. 确保您在Tomcat上部署了 clean 部署的应用程序。您的清理过程可能需要变化,但这是一般性的想法:

      Shutdown Tomcat, then verify it is no longer running. Remove the deployed war file and corresponding exploded version from your tomcat webapps directory. Remove the contents of the work and temp directories. Deploy and verify your recently build war file. Start Tomcat.

    2. 创建脚本可以节省时间。

      1. 如果所有其他方法都失败了,请添加一个调试日志,以便在首先调用断点时仔细检查代码。
      2. 我确信还有其他20件事可能出错。随意添加想法。

相关问题