Let me start by clarifying I have check every possible resource, tutorial, video, other stackoverflow questions that I could get my hands on that are related in order to try and find an answer to this. I'm using java 8
and Eclipse Luna Service Release 2 (4.4.2) with m2e plugin
, It's quite hard to believe but it seems there isn't a single example that clearly explains how you actually debug a Maven Java application USING ECLIPSE. There are no less than 40 different sources here are some
-
this runs the exec:exec goal from my pom.xml which looks like this
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>java</executable> <arguments> <argument>-classpath</argument> <classpath /> <argument>core.app.server</argument> <argument>-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address=*:49875 </argument> </arguments> <workingDirectory>${project.build.outputDirectory}</workingDirectory> </configuration> </plugin>
Ok, so far so good. At this point if I run the debug configuration the app launches and then hangs which I'm assuming it is waiting for the debugger to remotely connect based on the arguments in my pom.xml. So the app starts hangs and in Eclipse at this point I'm looking at this
At this point I've tried everything I can imagine. I notice the exec plugin launcher starts on a random port which in the picture is 51661, when in my exec arguments in the pom.xml I have it set to 49875 so this seems off. Another thing I noticed if I removed the
<argument>-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address=*:49875 </argument>
line from my pom.xml the app launches completely , runs fine but this gets me no where. I have tried to connect using a "Remote Java Application" configuration after the app launches this also does not work. I normally use IntelliJ which makes it an absolute breeze since everything is handled OOTB, unfortunately I have to get this working in Eclipse as well in a similar fashion.How do I configure the Debug Configuration in a way that will allow me to launch the app and hit my breakpoints?
EDIT 1 When setting
suspend=n
the app still hangs when launching with the argumentagentlib:jdwp
EDIT 2 In an effort to get this figured out without wasting another day on something that should be effortless, I tested running a
clean install
from and debug configuration and then tested using the run as commands provided by m2e shown below and the m2e commands work perfectly where as the same exact commands ran with a debug configuration fail for missing references.EDIT 3 Reading the documentation on the exec maven plugin here
- Set "my" breakpoint in:
package com.example; public class Demo { public static void main(String[] args) { int x = 0; x ; // just to set breakpoint somewhere System.out.println(x); } }
"Run" "Exec_Java" (suspend, and server flags (and all) have effect!)
Console(Exec_Java) should report:
... [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @ luna-res --- Listening for transport dt_socket at address: 49875 //!!
"Debug" "New_Configuration".
..and the breakpoint halts(, and we get the "switch perspective dialog";)