IntelliJ 调试断点不适用于 Tomcat 运行配置

时间:2021-02-09 19:16:12

标签: java maven tomcat intellij-idea remote-debugging

背景

我有一个带有调用一些转换器库的端点的小应用程序。我的 Run Configuration 属于 Tomcat 类型并部署了一个爆炸战争,这是我的应用程序。

在该应用程序的 pom.xml<dependencies> 中,我有一个需要调试的外部库。显然,该库在我的应用程序中被调用。

当我在 Tomcat Run Configuration 模式下启动 Debug 时,日志表明代理似乎已正确设置并且工件已成功部署(以下是我的日志子集)认为是相关的):

C:\Apps\apache-tomcat-8.5.56\bin\catalina.bat run
[2021-02-09 01:32:03,448] Artifact crs-classic-conv-endpoint:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE:   "C:\Users\me\AppData\Local\JetBrains\IntelliJIdea2020.3\tomcat\ac2f062f-8f6d-4769-8de5-120d70232ac9"
Using CATALINA_HOME:   "C:\Apps\apache-tomcat-8.5.56"
Using CATALINA_TMPDIR: "C:\Apps\apache-tomcat-8.5.56\temp"
Using JRE_HOME:        "C:\Apps\jdk-1.8.0_181_pki18"
Using CLASSPATH:       "C:\Apps\apache-tomcat-8.5.56\bin\bootstrap.jar;C:\Apps\apache-tomcat-8.5.56\bin\tomcat-juli.jar"
Connected to the target VM, address: '127.0.0.1:61873', transport: 'socket'
Connected to server
[2021-02-09 01:32:05,611] Artifact crs-classic-conv-endpoint:war exploded: Artifact is being deployed, please wait...
Root WebApplicationContext: initialization started 
09-Feb-2021 13:32:30.964 INFOS [RMI TCP Connection(5)-127.0.0.1] com.sun.xml.ws.server.MonitorBase.createRoot Metro monitoring rootname successfully set to: com.sun.metro:pp=/,type=WSEndpoint,name=-RetrieveCRSClassicContractService-RetrieveCRSClassicContractPort
Registering beans for JMX exposure on startup 
Bean with name 'loggingConfiguration' has been autodetected for JMX exposure 
Bean with name 'mailConfiguration' has been autodetected for JMX exposure 
Bean with name 'performanceConfiguration' has been autodetected for JMX exposure 
Bean with name 'propertiesConfiguration' has been autodetected for JMX exposure 
Located managed bean 'propertiesConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.PropertiesConfiguration] 
Located managed bean 'mailConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.MailConfiguration] 
Located managed bean 'performanceConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.PerformanceConfiguration] 
Located managed bean 'loggingConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.LoggingConfiguration] 
Registering beans for JMX exposure on startup 
Bean with name 'loggingConfiguration' has been autodetected for JMX exposure 
Bean with name 'mailConfiguration' has been autodetected for JMX exposure 
Bean with name 'performanceConfiguration' has been autodetected for JMX exposure 
Bean with name 'propertiesConfiguration' has been autodetected for JMX exposure 
Located managed bean 'propertiesConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.PropertiesConfiguration] 
Located managed bean 'mailConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.MailConfiguration] 
Located managed bean 'performanceConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.PerformanceConfiguration] 
Located managed bean 'loggingConfiguration': registering with JMX server as MBean [Foo.${service.name}.Configuration:name=ws-common-utils.LoggingConfiguration] 
Root WebApplicationContext: initialization completed in 15487 ms 
09-Feb-2021 13:32:32.585 INFOS [RMI TCP Connection(5)-127.0.0.1] com.sun.xml.ws.transport.http.servlet.WSServletDelegate.<init> WSSERVLET14 : initialisation du servlet JAX-WS
Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@167fa5b2: startup date [Tue Feb 09 13:32:32 EST 2021]; root of context hierarchy 
[2021-02-09 01:32:33,359] Artifact crs-classic-conv-endpoint:war exploded: Artifact is deployed successfully
[2021-02-09 01:32:33,359] Artifact crs-classic-conv-endpoint:war exploded: Deploy took 27,748 milliseconds

然后,我可以看到由于白色复选标记,我的断点已注册:

enter image description here

但是,这仅适用于模块的 src/main/java 目录中的代码。我正在尝试调试的库(位于 External Libraries 中)不会注册其断点:

enter image description here

我添加了几行日志记录,并修改了该库的 pom.xml 中的版本并在库和我的应用程序中运行 mvn clean install 以确保我指向正确的版本代码。


诊断

现在到了奇怪的部分。当我运行调用我的应用程序端点的测试时,我看到以下日志:

com.my.app.ExecutionServiceException: java.lang.NullPointerException: TheConverter.java, notWithinYearBoundaries line 1110
    at com.my.app.handleTransaction(MyAppEndpointHandler.java:143)

这向我证明,我在日志记录 (L1109) 上设置断点的库代码确实正在运行(并且我在 Tomcat 日志中看到了实际日志)。

此外,当我点击 MyAppEndpointHandler.java:143 时,IntelliJ 确实打开了我设置断点的类,该类被标记为已注册(是的,L61 与 {{ 1}}).


问题

  1. 当代码到达 L143 上注册的断点时,IntelliJ 甚至不会中断正在运行的应用程序以向我显示调试窗口。
  2. IntelliJ 拒绝在外部库中注册我的断点。

我尝试过的事情

这很令人不安,我尝试了很多不同的东西(我在 that other SO question 中看到的一堆东西,等等):

  1. L61
  2. 关闭所有项目,并删除clean & rebuildtarget.idea/
  3. 更新我的 IntelliJ 版本(从 *.iml2020.3
  4. 尝试另一个版本的 Tomcat
  5. 2020.3.2
  6. 还有更多...

值得一提的是,我团队中的另外两名开发人员报告说,在他们的机器上,他们没有遇到我的问题。而且我们似乎必须使用相同的 IntelliJ 配置和设置。


设置和运行配置

这是Invalidate Caches & Restart

这是我的 Tomcat Run Configuration 设置:


IntelliJ 调试控制台输出

这是控制台日志的部分版本:

Debugger

断点属性

1 个答案:

答案 0 :(得分:1)

原来是误会了。我以为 Test 类正在对 localhost Tomcat 实例进行网络调用,但实际上它直接调用了源代码。

这就是为什么当我在调试模式下启动 Tomcat 运行配置时,我会在我的源代码中得到一个注册的断点,但它永远不会挂起应用程序,尽管我看到了日志。

由于应用程序被配置为在 target 中的文件中输出日志,我认为日志来自 Tomcat。

从以调试模式启动的 Test 类步入,将我带到了应用程序代码,最终也到达了库代码。这也是为什么我在调试模式下启动Tomcat运行配置后正常运行Test类时,我看到来自库的日志,但没有看到注册的断点。

呃。那是一段令人尴尬且耗时的旅程。

相关问题