{"record":{"id":"fb01f376510760ab","repo":"spring-projects/spring-boot","slug":"could-not-invoke-shutdown-operation-fb01f3","errorCode":null,"errorMessage":"Could not invoke shutdown operation","messagePattern":"Could not invoke shutdown operation","errorType":"exception","errorClass":"MojoFailureException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java","lineNumber":186,"sourceCode":"\t\t\t\t\t+ \". Please make sure that no other process is using that port\", ex);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new MojoExecutionException(\"Failed to connect to MBean server at port \" + this.jmxPort, ex);\n\t\t}\n\t}\n\n\tprivate void doWaitForSpringApplication(MBeanServerConnection connection)\n\t\t\tthrows MojoExecutionException, MojoFailureException {\n\t\tfinal SpringApplicationAdminClient client = new SpringApplicationAdminClient(connection, this.jmxName);\n\t\ttry {\n\t\t\tCallable<@Nullable Boolean> isReady = () -> (client.isReady() ? true : null);\n\t\t\texecute(this.wait, this.maxAttempts, isReady);\n\t\t}\n\t\tcatch (ReflectionException ex) {\n\t\t\tthrow new MojoExecutionException(\"Unable to retrieve 'ready' attribute\", ex.getCause());\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new MojoFailureException(\"Could not invoke shutdown operation\", ex);\n\t\t}\n\t}\n\n\t/**\n\t * Execute a task, retrying it on failure.\n\t * @param <T> the result type\n\t * @param wait the wait time\n\t * @param maxAttempts the maximum number of attempts\n\t * @param callback the task to execute (possibly multiple times). The callback should\n\t * return {@code null} to indicate that another attempt should be made\n\t * @return the result\n\t * @throws Exception in case of execution errors\n\t */\n\tpublic <T> T execute(long wait, int maxAttempts, Callable<@Nullable T> callback) throws Exception {\n\t\tgetLog().debug(\"Waiting for spring application to start...\");\n\t\tfor (int i = 0; i < maxAttempts; i++) {\n\t\t\tT result = callback.call();\n\t\t\tif (result != null) {","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java#L168-L204","documentation":"Catch-all Exception block in doWaitForSpringApplication. IMPORTANT: the message ('Could not invoke shutdown operation') is misleading -- this code path protects the readiness POLL loop (execute on isReady), not shutdown. Any non-ReflectionException escaping the retry loop is wrapped as MojoFailureException with this message.","triggerScenarios":"Any exception other than ReflectionException escaping execute(wait, maxAttempts, isReady) during the readiness poll (e.g. MBeanException, RuntimeException from the isReady callable).","commonSituations":"Application threw during the ready check; JMX errors during polling that are not reflection failures; the message misleads users toward shutdown when the real cause is readiness.","solutions":["Inspect the wrapped cause (the real exception class) rather than trusting the message text","Re-run with -X for verbose JMX diagnostics","Verify the application isn't throwing during context refresh / ready evaluation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { doWaitForSpringApplication(connection); } catch (MojoFailureException ex) { /* message says 'shutdown' but real cause is readiness */ log.error(\"Readiness poll failed (message is misleading): {}\", ex.getCause()); throw ex; }","preventionTips":["Trust the wrapped cause class, not the message text","Re-run with -X to capture full JMX diagnostics","Verify the application is not throwing during context refresh"],"tags":["jmx","lifecycle","maven-plugin","misleading-message"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}