Maven plugin error on Windows when JAVA_HOME path contains spaces
See original GitHub issueThe gatling-maven-plugin fails with an error on Windows, when the JAVA_HOME path contains a space. The problem seems to be that the plugin cannot find the java executable.
We see this problem when running the plugin with the following conditions:
- Windows 7
- JDK 1.8.0_121
- Maven 3.3.9
- Gatling 2.2.4
- gatling-maven-plugin 2.2.4
- JDK installed at the default location:
C:\Program Files\Java\jdk1.8.0_121
- JAVA_HOME env variable set to:
C:\Program Files\Java\jdk1.8.0_121
The problem seems to depend on the Windows version. In particular, we have seen this happen on Windows 7; but we could not reproduce this on Windows 10, where everything works just fine.
We first observed this on a project we are working on, but we were able to reproduce the problem with the demo application (https://github.com/gatling/gatling-maven-plugin-demo). We simply cloned the demo project, and run mvn gatling:execute
without any modification to the project code, and the problem appeared.
This is the full error with stacktrace:
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:2.2.4:execute (default-cli) on project test: Gatling failed. Cannot run program “C:\Progra~1\Java\jdk1.8.0_121\bin\java" (in directory "."): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.gatling:gatling-maven-plugin:2.2.4:execute (default-cli) on project matchboxPerformanceTesting: Gatling failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Gatling failed.
at io.gatling.mojo.GatlingMojo.execute(GatlingMojo.java:219)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.io.IOException: Cannot run program "C:\Progra~1\Java\jdk1.8.0_121\bin\java" (in directory "."): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:277)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:334)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:164)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:151)
at io.gatling.mojo.Fork.run(Fork.java:120)
at io.gatling.mojo.GatlingMojo.executeGatling(GatlingMojo.java:274)
at io.gatling.mojo.GatlingMojo.iterateBySimulations(GatlingMojo.java:236)
at io.gatling.mojo.GatlingMojo.execute(GatlingMojo.java:214)
... 22 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 33 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
To get around this issue with white space in JAVA_HOME path, I created a symbolic link called Program-Files and used it in the JAVA_HOME variable. c:>mklink /J c:\Program-Files “c:\Program Files” https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/
No it’s not. This issue was because of the white space in the full name, before we were trying to use the short name instead.