{"id":"91f4ba25dff18a4d","repo":"spring-projects/spring-boot","slug":"process-terminated-with-exit-code","errorCode":null,"errorMessage":"Process terminated with exit code: {}","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/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JavaProcessExecutor.java#L57-L93","documentation":"Thrown by JavaProcessExecutor.run as a MojoExecutionException when the forked JVM exits with a code that is neither 0 (success) nor 130 (SIGINT). This is the plugin reporting that the application/process it launched (typically via spring-boot:run with fork, or an AOT/process goal) terminated abnormally. The plugin itself is healthy — the child process failed. Exit 130 is intentionally treated as success because Ctrl-C during run should not fail the build.","triggerScenarios":"spring-boot:run forking a JVM whose application throws an uncaught exception on startup; an AOT processing or test process exiting non-zero; the application's main method calling System.exit(nonzero); JVM failing to start (e.g. bad -Xmx, missing agent) and exiting with a JVM-reported code;OutOfMemoryError killing the JVM with a specific exit code.","commonSituations":"Application fails to boot (port in use, missing config, bean wiring error); JVM options are invalid (-Dspring-boot.run.jvmArguments); a -javaagent jar is missing or incompatible; native/AOT processor hits an error and exits 1; test process exits non-zero during process-test-aot.","solutions":["Scroll up in the build log — the forked process printed its own exception/stack trace immediately before this message; fix that root cause.","Run with -Dspring-boot.run.fork=false only if you need the failure to surface in-process (not always supported).","Validate JVM arguments: -Dspring-boot.run.jvmArguments and any -javaagent paths.","If the exit code is 137, suspect OOMKill/container memory limits and increase -Xmx or container memory."],"exampleFix":"// before — invalid JVM argument\nmvn spring-boot:run -Dspring-boot.run.jvmArguments=\"-Xmx512 -Xms256\"  // -Xmx missing unit\n// after\nmvn spring-boot:run -Dspring-boot.run.jvmArguments=\"-Xmx512m -Xms256m\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// When invoking spring-boot:run programmatically / wrapping the build\ntry {\n    // invoke run/process goal\n} catch (org.apache.maven.plugin.MojoExecutionException ex) {\n    String m = ex.getMessage();\n    if (m != null && m.startsWith(\"Process terminated with exit code:\")) {\n        int code = Integer.parseInt(m.substring(m.lastIndexOf(':') + 1).trim());\n        // surface child process logs; do not mask the real failure\n    }\n    throw ex;\n}","preventionTips":["Always read the forked process output above the error — the root cause is there, not in this message.","Validate -javaagent paths and -Dspring-boot.run.jvmArguments before running.","If exit code is 137, raise container/JVM memory limits."],"tags":["maven","spring-boot","run","process","jvm"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}