{"record":{"id":"55bf396c5a1ac7bd","repo":"spring-projects/spring-boot","slug":"process-terminated-with-exit-code-exitcode","errorCode":null,"errorMessage":"Process terminated with exit code: {exitCode}","messagePattern":"Process terminated with exit code: (.+?)","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JavaProcessExecutor.java","lineNumber":75,"sourceCode":"\t\tthis.runProcessCustomizer = runProcessCustomizer;\n\t}\n\n\tJavaProcessExecutor withRunProcessCustomizer(Consumer<RunProcess> customizer) {\n\t\tConsumer<RunProcess> combinedCustomizer = (this.runProcessCustomizer != null)\n\t\t\t\t? this.runProcessCustomizer.andThen(customizer) : customizer;\n\t\treturn new JavaProcessExecutor(this.mavenSession, this.toolchainManager, combinedCustomizer);\n\t}\n\n\tint run(File workingDirectory, List<String> args, Map<String, String> environmentVariables)\n\t\t\tthrows MojoExecutionException {\n\t\tRunProcess runProcess = new RunProcess(workingDirectory, getJavaExecutable());\n\t\tif (this.runProcessCustomizer != null) {\n\t\t\tthis.runProcessCustomizer.accept(runProcess);\n\t\t}\n\t\ttry {\n\t\t\tint exitCode = runProcess.run(true, args, environmentVariables);\n\t\t\tif (!hasTerminatedSuccessfully(exitCode)) {\n\t\t\t\tthrow new MojoExecutionException(\"Process terminated with exit code: \" + exitCode);\n\t\t\t}\n\t\t\treturn exitCode;\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new MojoExecutionException(\"Process execution failed\", ex);\n\t\t}\n\t}\n\n\tRunProcess runAsync(File workingDirectory, List<String> args, Map<String, String> environmentVariables)\n\t\t\tthrows MojoExecutionException {\n\t\ttry {\n\t\t\tRunProcess runProcess = new RunProcess(workingDirectory, getJavaExecutable());\n\t\t\trunProcess.run(false, args, environmentVariables);\n\t\t\treturn runProcess;\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new MojoExecutionException(\"Process execution failed\", ex);\n\t\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JavaProcessExecutor.java#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: mvn -Pnative spring-boot:process-aot   (OOM during AOT, exit 137)\n// after:  mvn -Pnative -Dspring-boot.aot.forkJvmArgs='-Xmx2g' spring-boot:process-aot","handlingStrategy":"try-catch","validationCode":"// Pre-validate fork inputs (memory, classpath, JDK) before invoking:\nassert jdkToolchainExists();\nassert forkedClasspathResolves();\n// Then invoke; the message echoes the real exit code for diagnosis.","typeGuard":null,"tryCatchPattern":"try {\n    // invoke goal using JavaProcessExecutor.run\n} catch (MojoExecutionException ex) {\n    if (ex.getMessage().startsWith(\"Process terminated with exit code:\")) {\n        int code = Integer.parseInt(ex.getMessage().substring(ex.getMessage().lastIndexOf(' ') + 1));\n        // surface child process logs above; do NOT silently retry unchanged\n    }\n    throw ex;\n}","preventionTips":["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."],"tags":["spring-boot","maven-plugin","process","fork","lifecycle"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}