spring-projects/spring-boot · error · MojoExecutionException
Process terminated with exit code: {exitCode}
Error message
Process terminated with exit code: {exitCode} What it means
MojoExecutionException thrown by JavaProcessExecutor.run when the forked process exits with a code that is neither 0 nor EXIT_CODE_SIGINT. The message echoes the actual exit code so the underlying process failure is identifiable. This wraps a deliberate, completed run — the process did terminate, just unsuccessfully.
Source
Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JavaProcessExecutor.java:75
this.runProcessCustomizer = runProcessCustomizer;
}
JavaProcessExecutor withRunProcessCustomizer(Consumer<RunProcess> customizer) {
Consumer<RunProcess> combinedCustomizer = (this.runProcessCustomizer != null)
? 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);
}View on GitHub (pinned to 270dfe353f)
Solutions
- Look immediately above in the log — the forked process printed its own error before exiting with that code.
- Increase forked memory / verify the toolchain JDK matches the project's target.
- Run the same command outside Maven to reproduce and get the full stack trace.
- If exit code is 130 (SIGINT) it is treated as success; for other non-zero codes, fix the root cause inside the child process.
Example fix
// before: mvn -Pnative spring-boot:process-aot (OOM during AOT, exit 137) // after: mvn -Pnative -Dspring-boot.aot.forkJvmArgs='-Xmx2g' spring-boot:process-aot
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate fork inputs (memory, classpath, JDK) before invoking: assert jdkToolchainExists(); assert forkedClasspathResolves(); // Then invoke; the message echoes the real exit code for diagnosis.
Try / catch
try {
// invoke goal using JavaProcessExecutor.run
} catch (MojoExecutionException ex) {
if (ex.getMessage().startsWith("Process terminated with exit code:")) {
int code = Integer.parseInt(ex.getMessage().substring(ex.getMessage().lastIndexOf(' ') + 1));
// surface child process logs above; do NOT silently retry unchanged
}
throw ex;
} Prevention
- Always read the forked-process logs above the error — they hold the root cause.
- Don't retry the same command unchanged; change an input first.
- Pin a toolchain JDK compatible with the project's target.
When it happens
Trigger: Calling run(...) (synchronous fork) for an AOT/test process or any Mojo that delegates to JavaProcessExecutor.run, and the child JVM exits non-zero (and not SIGINT). Examples: ProcessAotMojo/ProcessTestAotMojo forked AOT generation that fails inside the forked process; run goal with a failing main.
Common situations: Forked AOT process crashes (OOM, missing class, compile error in the host compiler); the application main throws and exits non-zero; toolchain JDK incompatible; native-image or AOT processor emits an error and exits 1.
Related errors
- A jar or war file is required for building image
- Process execution failed
- Source file is not available, make sure 'package' runs as pa
- Failed to load layers configuration with name '%s': '%s' not
- Failed to process custom layers configuration {source}
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/55bf396c5a1ac7bd.
Report an issue: GitHub.