question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maven plugin error on Windows when JAVA_HOME path contains spaces

See original GitHub issue

The 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:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mdarkecommented, May 10, 2018

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/

0reactions
slandellecommented, Apr 25, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to install Maven on Windows: "JAVA_HOME is set to ...
The problems are to do with your paths. Make sure that the directory "E:\java resources\apache-maven-2.2.0\bin" is on your command search path.
Read more >
Fix JAVA_HOME errors | Invalid directory | Not set or defined
One very common developer mistake that leads to the JAVA_HOME is set to an invalid directory error is pointing JAVA_HOME to the \bin...
Read more >
Installer Fails on Windows Due to Spaces in JAVA_HOME
It should not contain spaces. Cause. The installer interprets the tilde as white-space. Resolution. Set %JAVA_HOME% to the expanded value, e.g. ...
Read more >
Release Notes – Maven 3.5.0
In Maven 3.3.9, we have removed bindings for maven-ejb3-plugin because it does ... Windows and Unix launchers does not work for directory names...
Read more >
eclipse.ini - Eclipsepedia
-XX VM arguments are subject to change without notice, even during minor updates. If the JVM keeps exiting with code 2 instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found