Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote debugging with mvnDebug, doesn't stop at breakpoint

Inspired by https://stackoverflow.com/a/14853683/286795, I'm trying to remotely debug a Maven project using mvnDebug and IntelliJ. However, the execution doesn't stop on my breakpoints. To reproduce a simple Hello World example:

On the local machine:

git clone https://github.com/LableOrg/java-maven-junit-helloworld.git
cd java-maven-junit-helloworld
mvnDebug test

On the remote machine:

  1. Open IntelliJ
  2. Check out from Version Control->Git, set URL: https://github.com/LableOrg/java-maven-junit-helloworld.git, Clone
  3. Open the project
  4. Open Hello.java, set a breakpoint at the line that says printer.println(HELLO);

  5. Run->Debug...->Edit Configurations..., Add New Configuration->Remote

  6. Set Debugger mode: Attach, Transport: Socket, Host:, Port:8000
  7. Apply, Debug

The tests will now run WITHOUT stopping at the breakpoint. Why?

like image 563
matthiash Avatar asked Mar 20 '19 12:03

matthiash


People also ask

How do I stop remote debugging?

05 On the General settings panel, under Debugging, select Off next to Remote debugging setting to disable remote debugging using Microsoft Visual Studio for the selected Azure App Services web application.

How do I stop debug in intelliJ?

Terminate a debugger sessionClick the Stop button in the Debug tool window. Alternatively, press Ctrl+F2 and select the process to terminate (if there are two or more of them).


1 Answers

While running the mvnDebug command, use -DforkMode=never.

so your maven command will look like this:

mvnDebug -DforkMode=never -Dmaven.surefire.debug clean install

For more info on -DforkMode=never, read here

like image 83
Sadaf Rasool Avatar answered Sep 24 '22 18:09

Sadaf Rasool