Developer404
Developer404

Reputation: 5962

Cannot run program CreateProcess error=206, The filename or extension is too long

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)*

Upvotes: 10

Views: 33871

Answers (6)

Javier
Javier

Reputation: 12398

Based on the answer from Developer404, instead of moving the .m2 repository, just mount it to a drive. That way the command line will be shorter and it will likely fit within limits. (Not an ideal solution, but it works with Spring Boot 3)

subst M: C:\Users\Javier\.m2\repository
mvn -Dmaven.repo.local=M:\ spring-boot:run

Upvotes: 2

M Alok
M Alok

Reputation: 1081

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

Upvotes: 9

developer
developer

Reputation: 429

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>

Upvotes: 15

ALAOUI Jaouhar
ALAOUI Jaouhar

Reputation: 71

change

<fork>true</fork>

to

<fork>false</fork>

Upvotes: 7

Developer404
Developer404

Reputation: 5962

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

Upvotes: -3

Trushit Shekhda
Trushit Shekhda

Reputation: 561

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.

Upvotes: 6

Related Questions