8

I get the titled error when I use jvmarguments in the pom file. I'm using mvnw command with the below plugin to enable debugging. If I remove the jvm argument, it works. But I want to enable remote debugging with the mvnw command

Code Snippet:

<plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <mainClass>${start-class}</mainClass>
            <executable>true</executable>
            <fork>true</fork>
            <jvmArguments>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmArguments> 
        </configuration>
</plugin>

Error:

*[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.7.RELEASE:run (default-cli) on project dxcgateway: Could not exec java: Cannot run program "C:\Program Files\Java\jdk1.8.0_202\jre\bin\java.exe": CreateProcess error=206, The filename or extension is too long -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.7.RELEASE:run (default-cli) on project dxcg ateway: Could not exec java

Caused by: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0_202\jre\bin\java.exe": CreateProcess error=206, The filename or extension is too long at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048) at org.springframework.boot.loader.tools.RunProcess.run (RunProcess.java:77)

Caused by: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0_202\jre\bin\java.exe": CreateProcess error=206, The filename or extension is too long at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048) at org.springframework.boot.loader.tools.RunProcess.run (RunProcess.java:77)*

Developer404
  • 5,716
  • 16
  • 64
  • 102
  • [Forking](https://docs.spring.io/spring-boot/docs/current/maven-plugin/run-mojo.html#fork) is enabled by default since Spring Boot 2.2. See https://stackoverflow.com/questions/61125404/since-2-2-0-spring-boot-maven-plugin-create-2-java-process-may-cause-createproc question and solution – Grigory Kislin Apr 09 '20 at 19:22

5 Answers5

12

For me I had the similar exception, below change solved the issue

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <fork>false</fork>
            </configuration>
        </plugin>
developer
  • 401
  • 1
  • 4
  • 15
7

change

<fork>true</fork>

to

<fork>false</fork>
6

If you are using IntelliJ Idea platform just change the launch configuration to avoid using the default shorten line

enter image description here

This worked for me.

Shekhar Rai
  • 2,008
  • 2
  • 22
  • 25
Trushit Shekhda
  • 563
  • 7
  • 18
5

This is caused by a Windows OS limitation. To solve it:

  1. Move .m2 repository to c:\
  2. Open settings.xml from %MAVEN_HOME%/conf and look for \<settings>.\<localRepository>(uncomment it if its commented out already) and change its value to c:/.m2/repository
  3. Save the file and run the build again
Nicolás Alarcón Rapela
  • 2,714
  • 1
  • 18
  • 29
Alok Mishra
  • 926
  • 13
  • 39
-4

I used the below commandand it worked. mvnw -Dmaven.repo.local=C:/mavenRepo

Developer404
  • 5,716
  • 16
  • 64
  • 102