简体   繁体   English

如何通过Eclipse中的远程Java应用程序调试来调试Groovy代码

[英]How to debug Groovy code via the remote Java application debugging in Eclipse

I'm struggling to debug an application that builds as a Sling bundle. 我正在努力调试构建为Sling包的应用程序。 The application is almost entirely Groovy code (I have the Groovy Eclipse plug-in), and Eclipse (using Maven) is building the .jar and installing it in Sling without any problems. 该应用程序几乎完全是Groovy代码(我有Groovy Eclipse插件),Eclipse(使用Maven)构建.jar并在Sling中安装它没有任何问题。

However, it's not able to debug. 但是,它无法调试。 I have followed instructions to set up remote debugging, which I gather is necessary for debugging Sling apps - specifically, I launch Sling with the following command: 我已按照说明设置远程调试,我收集这些是调试Sling应用程序所必需的 - 具体来说,我使用以下命令启动Sling:

java -Xdebug -Xnoagent -Djava.io.tmpdir=/c/Users/nickgolding1/temp -Xmx1024m -Xrunjdwp:transport=dt_socket,address=30303,server=y,suspend=n -jar org.apache.sling.launchpad-6-SNAPSHOT-standalone.jar -p 8080

... and then set up a debug configuration in Eclipse, of type "Remote Java Application", pointing to my project, Connection Type "Standard (Socket Attach)", host localhost, port 30303. This configuration seems to start ok - at least, I don't get any feedback suggesting it hasn't - but breakpoints I set in the Groovy code don't actually break execution of requests to the Sling app. ...然后在Eclipse中设置一个类型为“远程Java应用程序”的调试配置,指向我的项目,连接类型“标准(套接字连接)”,主机localhost,端口30303.此配置似乎开始正常 - 在至少,我没有得到任何反馈表明它没有 - 但我在Groovy代码中设置的断点实际上并没有破坏对Sling应用程序的请求执行。

I've seen a couple of posts on various forums that show people having problems debugging Groovy code via the Remote Java App configuration, where they don't have a problem with Java code. 我在各种论坛上看到了一些帖子,这些帖子显示人们在通过远程Java应用程序配置调试Groovy代码时遇到问题,他们在Java代码中没有问题。 Unfortunately my app is all Groovy and no Java, so I can't verify this is the case here. 不幸的是我的应用程序都是Groovy而且没有Java,因此我无法验证这是否就是这种情况。

Any thoughts appreciated! 任何想法赞赏!

First, a suggestion. 首先,一个建议。 Set suspend=y in your Xrunjdwp:transport option. 在Xrunjdwp:transport选项中设置suspend=y This will suspend in main and will give you a better idea as to whether or not your problem is with your debug options or the Groovy code. 这将暂停在main中,并且可以让您更好地了解您的问题是否与您的调试选项或Groovy代码有关。

Now, on to something more complicated. 现在,更复杂的事情。 Yes. 是。 There are some issues regarding debugging of remote Groovy code. 有关调试远程Groovy代码的一些问题。 The problem generally comes about when Groovy code is loaded dynamically. 当动态加载Groovy代码时,通常会出现问题。 In this case the debug name often does not match the source name and the debugger does not know how to match the dynamically loaded class file with the original source code. 在这种情况下,调试名称通常与源名称不匹配,调试器不知道如何将动态加载的类文件与原始源代码进行匹配。

One such problem is described here (and there are no doubt other places where similar things happen): https://jira.springsource.org/browse/SPR-7113 这里描述了一个这样的问题(毫无疑问,其他地方也会发生类似的事情): https//jira.springsource.org/browse/SPR-7113

So, my suggestion to you is that if possible you should ensure that your groovy code is pre-compiled before being sent to the server. 所以,我的建议是,如果可能的话,你应该确保你的groovy代码在被发送到服务器之前进行了预编译。 (And also set suspend=y .) (还设置suspend=y 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM