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

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

本文介绍了如何通过Eclipse中的远程Java应用程序调试来调试Groovy代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力调试构建为Sling包的应用程序。应用程序几乎完全是Groovy代码(我有Groovy Eclipse插件),Eclipse(使用Maven)正在构建.jar并在Sling中安装它。

但是,它无法进行调试。我已经按照说明设置了远程调试,我收集这些调试是调试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 

...然后设置在Eclipse中调试配置类型远程Java应用程序,指向我的项目,连接类型标准(套接字连接),主机本地主机,端口30303.此配置似乎开始好 - 至少,我没有得到任何反馈都暗示它没有 - 但我在Groovy代码中设置的断点实际上并不会中断对Sling应用程序的请求。



我见过一对夫妇在各种论坛上的帖子,显示人们在通过远程Java应用程序配置调试Groovy代码时遇到问题,他们不喜欢Java代码没有问题。不幸的是,我的应用程序都是Groovy,没有Java,所以我无法验证这是这种情况。



任何想法都会赞赏!

解决方案

首先,一个建议。在你的Xrunjdwp:transport选项中设置 suspend = y 。这将暂停在main中,并会给你一个更好的想法,以确定你的问题是否与你的调试选项或Groovy代码有关。



现在,复杂。是。关于远程Groovy代码的调试有一些问题。这个问题通常出现在Groovy代码动态加载的时候。在这种情况下,调试名称通常与源名称不匹配,调试器不知道如何将动态加载的类文件与原始源代码相匹配。



其中一个问题在这里描述(毫无疑问,类似的事情发生在其他地方):



所以,我对你的建议是,如果可能你应该确保你的groovy代码在被发送到服务器之前被预先编译。 (并且设置 suspend = y 。)


I'm struggling to debug an application that builds as a Sling bundle. 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.

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:

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.

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. Unfortunately my app is all Groovy and no Java, so I can't verify this is the case here.

Any thoughts appreciated!

解决方案

First, a suggestion. Set suspend=y in your Xrunjdwp:transport option. 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.

Now, on to something more complicated. Yes. There are some issues regarding debugging of remote Groovy code. The problem generally comes about when Groovy code is loaded dynamically. 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

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. (And also set suspend=y.)

这篇关于如何通过Eclipse中的远程Java应用程序调试来调试Groovy代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 06:32