7

I run Jetty from the command line with:

export GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n"

gradle jettyRun

and see:

Listening for transport dt_socket at address: 9999

... then in IntelliJ Idea (Ultimate 12.1.3) I create a new remote debug configuration with all defaults, changing only the port to 9999.

When I start (debug) using the remote configuration, I see:

Connected to the target VM, address: 'localhost:9999', transport: 'socket'

... which makes me think everything is working as expected.

Then I make requests that should result in hitting breakpoints. But the breakpoints are never triggered.

What am I doing wrong?

Thanks.

Robert Christian
  • 18,218
  • 20
  • 74
  • 89
  • One theory is that I may be telling *Gradle* and not *Jetty* to expose a debug port. And looking at the JettyRun documentation, there may be no way to do this. http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.jetty.JettyRun.html#org.gradle.api.plugins.jetty.JettyRun:jettyConfig ... looking into solution using the Cargo plugin. However looking at the tomcat plugin, what I am doing looks to be correct: https://github.com/bmuschko/gradle-tomcat-plugin – Robert Christian May 20 '13 at 18:37
  • Your solution works for me. I'm using gradle 1.5. Your solution above is the same with http://stackoverflow.com/questions/9315398/how-to-run-jetty-via-gradle-in-debug-mode. – ceilfors Jun 22 '13 at 06:19
  • if you see Connected to the target VM, address: 'localhost:9999', transport: 'socket' that means you're connected. I will add system.out to rule out you're not triggering the breakpoints – Luis Ramirez-Monterosa Oct 14 '13 at 16:09
  • This should work just fine. Jetty and Gradle run in the same JVM. – Benjamin Muschko Nov 11 '13 at 04:09

2 Answers2

5

You could have the "org.gradle.jvmargs" variable set in your gradle.properties file. This causes the JVM to be forked which means you are no longer debugging the right process.

In this case, you could either not set the "org.gradle.jvmargs" or pass it the debug parameters eg.

org.gradle.jvmargs=-XX:MaxPermSize=128m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1233

Setting the debug parameters in org.gradle.jvmargs would configure the forked process for debugging.

0

In IntelliJ (at least on 12.1.5) you can just go to JetGradle, right click on jettyRun and then click on Debug.

eduardohl
  • 1,176
  • 2
  • 10
  • 23
  • I rarely downvote, but I have a strong wish to do it, too. "you can just go to JetGradle"... Really? And how? Do you see here that JetGradle discussed or even mentioned? – Gangnus Jan 13 '17 at 15:47
  • Good point. I guess I had installed the plugin and didn't notice. I think it doesn't even exist by now... – eduardohl Jan 24 '17 at 16:35