spring-projects/spring-boot · error · MojoExecutionException
Process execution failed
Error message
Process execution failed
What it means
MojoExecutionException thrown by the synchronous JavaProcessExecutor.run path when RunProcess.run throws an IOException — i.e., the process could not be launched or its I/O streams failed, distinct from a clean non-zero exit (which is the sibling message above). The original IOException is chained.
Solutions
- Inspect the chained IOException — `Cannot run program ...` typically indicates a missing/invalid java executable.
- Verify the configured toolchain JDK is installed and `java -version` works from that path.
- Ensure the working directory exists and is writable by the Maven process.
- On Windows, reduce the argument count or use argfile/@-file expansion if command-line length is the issue.
Example fix
// before: <toolchains><jdk><version>21</version><vendor>temurin</vendor></jdk></toolchains> (JDK not installed at expected path) // after: install Temurin 21 and re-run `mvn spring-boot:run`
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the fork launch inputs:
File javaHome = new File(System.getenv("JAVA_HOME"));
File javaBin = new File(javaHome, "bin/java");
if (!javaBin.canExecute()) {
throw new IllegalStateException("JAVA_HOME java not executable: " + javaBin);
}
if (workingDirectory != null && !workingDirectory.isDirectory()) {
throw new IllegalStateException("Working dir missing: " + workingDirectory);
} Try / catch
try {
// invoke goal using JavaProcessExecutor.run
} catch (MojoExecutionException ex) {
if ("Process execution failed".equals(ex.getMessage()) && ex.getCause() instanceof IOException) {
// verify toolchain/JAVA_HOME and working dir, then retry with corrected config
}
throw ex;
} Prevention
- Pin a toolchain JDK and verify `java -version` in CI.
- Ensure the working directory exists before forking.
- On Windows, watch command-line length limits.
When it happens
Trigger: IOException from RunProcess.run(true, ...) when starting or communicating with the forked JVM: java executable missing, working directory inaccessible, broken pipe on stdout/stderr, or environment setup failure.
Common situations: Toolchain points to a non-existent JAVA_HOME; workingDirectory doesn't exist or isn't writable; too-long command line on Windows hitting Process limits; antivirus blocking the fork; environment variables contain invalid values for the platform.
Related errors
- Process terminated with exit code
- Unable to build classpath
- A jar or war file is required for building image
- Can't parse ' ' to instant
- Could not build classpath
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/0908c8394c7dc2fc.
Report an issue: GitHub.
Appendix: source
Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JavaProcessExecutor.java:80
? this.runProcessCustomizer.andThen(customizer) : customizer;
return new JavaProcessExecutor(this.mavenSession, this.toolchainManager, combinedCustomizer);
}
int run(File workingDirectory, List<String> args, Map<String, String> environmentVariables)
throws MojoExecutionException {
RunProcess runProcess = new RunProcess(workingDirectory, getJavaExecutable());
if (this.runProcessCustomizer != null) {
this.runProcessCustomizer.accept(runProcess);
}
try {
int exitCode = runProcess.run(true, args, environmentVariables);
if (!hasTerminatedSuccessfully(exitCode)) {
throw new MojoExecutionException("Process terminated with exit code: " + exitCode);
}
return exitCode;
}
catch (IOException ex) {
throw new MojoExecutionException("Process execution failed", ex);
}
}
RunProcess runAsync(File workingDirectory, List<String> args, Map<String, String> environmentVariables)
throws MojoExecutionException {
try {
RunProcess runProcess = new RunProcess(workingDirectory, getJavaExecutable());
runProcess.run(false, args, environmentVariables);
return runProcess;
}
catch (IOException ex) {
throw new MojoExecutionException("Process execution failed", ex);
}
}
private boolean hasTerminatedSuccessfully(int exitCode) {
return (exitCode == 0 || exitCode == EXIT_CODE_SIGINT);
}View on GitHub (pinned to 270dfe353f)