{"record":{"id":"e5443ccf25ed89fd","repo":"spring-projects/spring-boot","slug":"could-not-invoke-shutdown-operation","errorCode":null,"errorMessage":"Could not invoke shutdown operation","messagePattern":"Could not invoke shutdown operation","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringApplicationAdminClient.java","lineNumber":93,"sourceCode":"\t\t\tthrow new MojoExecutionException(ex.getMessage(), ex);\n\t\t}\n\t}\n\n\t/**\n\t * Stop the application managed by this instance.\n\t * @throws MojoExecutionException if the JMX service could not be contacted\n\t * @throws IOException if an I/O error occurs\n\t * @throws InstanceNotFoundException if the lifecycle mbean cannot be found\n\t */\n\tvoid stop() throws MojoExecutionException, IOException, InstanceNotFoundException {\n\t\ttry {\n\t\t\tthis.connection.invoke(this.objectName, \"shutdown\", null, null);\n\t\t}\n\t\tcatch (ReflectionException ex) {\n\t\t\tthrow new MojoExecutionException(\"Shutdown failed\", ex.getCause());\n\t\t}\n\t\tcatch (MBeanException ex) {\n\t\t\tthrow new MojoExecutionException(\"Could not invoke shutdown operation\", ex);\n\t\t}\n\t}\n\n\tprivate ObjectName toObjectName(String name) {\n\t\ttry {\n\t\t\treturn new ObjectName(name);\n\t\t}\n\t\tcatch (MalformedObjectNameException ex) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid jmx name '\" + name + \"'\");\n\t\t}\n\t}\n\n\t/**\n\t * Create a connector for an {@link javax.management.MBeanServer} exposed on the\n\t * current machine and the current port. Security should be disabled.\n\t * @param port the port on which the mbean server is exposed\n\t * @return a connection\n\t * @throws IOException if the connection to that server failed","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringApplicationAdminClient.java#L75-L111","documentation":"MBeanException during stop() means the 'shutdown' MBean operation itself threw an application-level exception (a clean throw from the bean, distinct from ReflectionException which wraps JVM-level reflective failures). Wrapped as MojoExecutionException preserving the original MBeanException as cause.","triggerScenarios":"The shutdown operation on the lifecycle MBean threw an application exception (e.g. LifecycleProcessor failed, a SmartLifecycle bean errored on stop).","commonSituations":"Custom SmartLifecycle beans blocking or failing during close; @PreDestroy methods throwing; shutdown hook contention.","solutions":["Inspect the wrapped MBeanException for the underlying cause","Review application shutdown logic (SmartLifecycle, @PreDestroy)","Ensure no custom Lifecycle blocks ApplicationContext.close()"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { client.stop(); } catch (MojoExecutionException ex) { log.error(\"Application threw during shutdown: {}\", ex.getCause()); /* decide: force kill or report */ }","preventionTips":["Audit SmartLifecycle and @PreDestroy methods for throwing","Inspect the wrapped MBeanException cause for the real shutdown error","Test shutdown path explicitly during development"],"tags":["jmx","shutdown","maven-plugin"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}