【问题标题】:Remote Debug with IntelliJ使用 IntelliJ 进行远程调试
【发布时间】:2019-09-22 19:21:42
【问题描述】:

我需要有关 intell J IDE 上远程调试选项的帮助,我已成功连接到 Digital Oceans VM 提供的远程主机,但我无法从我的 IDE 开始调试。

这是显示本地计算机 (Ubuntu 18.04) 上正确连接的图像:

之前我在远程主机(Ubuntu 18.04)上设置了我的 Spring Boot 的 VM 执行:

.../target# java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar balak-cliente-rest-0.0.1-SNAPSHOT.jar    
Listening for transport dt_socket at address: 5005
      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v2.1.6.RELEASE)

2019-09-22 18:22:55.904  INFO 11937 --- [           main] c.t.s.app.ClienteRestApplication         : Starting ClienteRestApplication v0.0.1-SNAPSHOT on desarrollosfelipeinostroza with PID 11937 (/desarrollos/balak/tudicom-ws-rest/target/balak-cliente-rest-0.0.1-SNAPSHOT.jar started by root in /desarrollos/balak/tudicom-ws-rest/target)
2019-09-22 18:22:55.922  INFO 11937 --- [           main] c.t.s.app.ClienteRestApplication         : No active profile set, falling back to default profiles: default
2019-09-22 18:23:02.905  INFO 11937 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$5e2153d6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-22 18:23:03.531  INFO 11937 --- [           main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2019-09-22 18:23:04.897  INFO 11937 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 7171 (http)
2019-09-22 18:23:05.135  INFO 11937 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-09-22 18:23:05.137  INFO 11937 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-09-22 18:23:05.614  INFO 11937 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-09-22 18:23:05.618  INFO 11937 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 9280 ms
2019-09-22 18:23:07.371  INFO 11937 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-09-22 18:23:08.479  WARN 11937 --- [           main] o.s.x.transform.TransformerFactoryUtils  : http://javax.xml.XMLConstants/property/accessExternalDTD property not supported by org.apache.xalan.processor.TransformerFactoryImpl
2019-09-22 18:23:08.479  WARN 11937 --- [           main] o.s.x.transform.TransformerFactoryUtils  : http://javax.xml.XMLConstants/property/accessExternalStylesheet property not supported by org.apache.xalan.processor.TransformerFactoryImpl
2019-09-22 18:23:08.844  INFO 11937 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 7171 (http) with context path ''
2019-09-22 18:23:08.853  INFO 11937 --- [           main] c.t.s.app.ClienteRestApplication         : Started ClienteRestApplication in 16.567 seconds (JVM running for 18.499)

然后我将 Postman 的请求发送到端点以开始调试,但远程服务器上的应用程序在我的 IDE 中都没有发生任何事情。 我在没有用于传输的 VM 参数的情况下进行测试,以验证来自邮递员的调用并且应用程序响应,但是当我输入这些参数时,邮递员无法随他的请求到达。

需要了解的重要事项:

  • 本地机运行 openjdk 版本“1.8.0_222”(Ubuntu 18.04)
  • 远程调试选项

  • 在调试器菜单上,这是我的选项(本地 m.):

  • 远程机器 openjdk 版本“11.0.4”(Ubuntu 18.04)

更新添加更多信息:

【问题讨论】:

  • 您可以查看Java debugger logs 以尝试了解更多详细信息为什么卡住了。
  • 还可以使用jstack 获取线程转储,以查看应用程序在您的服务器上执行的操作以及为什么它没有响应。线程转储可能有助于识别问题。
  • 您可以通过 pastebin 共享调试器日志和 jstack 输出,以便其他人可以查看。
  • @CrazyCoder 我已经尽可能地更新了最完整的信息

标签: java intellij-idea remote-debugging


【解决方案1】:

我通过在网络部分向我的虚拟机添加更多规则解决了这个问题:

  1. HTTP (80) 用于监听来自 SOAP UI 的 HTTP 请求
  2. 用于 ping 的 ICMP
  3. 自定义打开端口(在我的情况下为 7171),因为在这些端口上配置了 Spring Boot 控制器,但我认为这不是很有用,因为打开 80 端口就足够了。
  4. 自定义打开端口(在我的例子中是 5005)用于 IntellJ 和远程主机之间的连接。
  5. 在我的 IDE (intellJ) 右侧部分的 Maven slap 中,我标记了干净和安装选项,因为我需要确保我在本地和远程主机上的代码版本相同,然后从我的本地目标文件夹我把我的 .jar 放到远程主机上,然后我用命令和那些参数运行了那个 .jar,是的!当我向本地 IDE 上的远程主机发送请求时到达并激活了断点。

感谢社区,再见!

【讨论】:

    猜你喜欢
    • 2012-07-23
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 2018-02-02
    • 2015-06-18
    • 2016-07-01
    • 1970-01-01
    • 2017-02-03
    相关资源
    最近更新 更多