Vscode-java-debug: Remote debugging not working with Java 9.0.1

Created on 22 Dec 2017  路  4Comments  路  Source: microsoft/vscode-java-debug

Remote debugging in spring boot projects doesn't work with Java jdk 9.0.1 (tested with multiple spring boot projects in Java jdk 9.0.1, none of them works).

Gets error "Failed to attach to remote debuggee VM. Reason: java.net.ConnectException: Connection refused: connect" when try to remote debug. Spring boot doesn't stop to wait for the debugger to attach.

Run command:

$ mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
Environment
  • Operating System: windows 10
  • JDK version: 9.0.1
  • Visual Studio Code version: 1.19.1
  • Java extension version: 0.16.0
  • Java Debugger extension version: 0.5.0

Most helpful comment

I have found out that to run remote debugging with the new version of spring boot (2.x.x, supports Java JDK 9), command line argument needs to be changed from -Drun.jvmArguments to -Dspring-boot.run.jvmArguments. The new spring-boot:run command for remote debugging should be:

$ mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

For future reference, check the command line argument for adding JVM arguments to spring-boot:run here:
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java#L105
Excerpt:

    @Parameter(property = "spring-boot.run.jvmArguments")
    private String jvmArguments;

All 4 comments

What's your spring-boot version? Refers to spring-boot wiki: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-Java-9, spring-boot 1.5.x doesn't support java 9.

Sorry I didn't mention my spring boot version. It's 2.0.0.M7 . Version 2.x should support Java 9.

The error message "java.net.ConnectException: connection refused" generally means the debug port 5005 is not really opened at your program. Could you share the console message for the cmd mvn spring-boot:run? Besides, can you remote debug it with other IDEs such as eclipse/intellij?

I have found out that to run remote debugging with the new version of spring boot (2.x.x, supports Java JDK 9), command line argument needs to be changed from -Drun.jvmArguments to -Dspring-boot.run.jvmArguments. The new spring-boot:run command for remote debugging should be:

$ mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

For future reference, check the command line argument for adding JVM arguments to spring-boot:run here:
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java#L105
Excerpt:

    @Parameter(property = "spring-boot.run.jvmArguments")
    private String jvmArguments;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivenxu picture ivenxu  路  8Comments

TheSinding picture TheSinding  路  6Comments

dgileadi picture dgileadi  路  3Comments

mentaloaf picture mentaloaf  路  6Comments

srfrnk picture srfrnk  路  5Comments