{"record":{"id":"aafe423162f84aee","repo":"spring-projects/spring-boot","slug":"spring-application-lifecycle-jmx-bean-not-found-c","errorCode":null,"errorMessage":"Spring application lifecycle JMX bean not found. Could not stop application gracefully","messagePattern":"Spring application lifecycle JMX bean not found\\. Could not stop application gracefully","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java","lineNumber":94,"sourceCode":"\t\t\treturn;\n\t\t}\n\t\tgetLog().info(\"Stopping application...\");\n\t\ttry (JMXConnector connector = SpringApplicationAdminClient.connect(this.jmxPort)) {\n\t\t\tMBeanServerConnection connection = connector.getMBeanServerConnection();\n\t\t\tstop(connection);\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\t// The response won't be received as the server has died - ignoring\n\t\t\tgetLog().debug(\"Service is not reachable anymore (\" + ex.getMessage() + \")\");\n\t\t}\n\t}\n\n\tprivate void stop(MBeanServerConnection connection) throws IOException, MojoExecutionException {\n\t\ttry {\n\t\t\tnew SpringApplicationAdminClient(connection, this.jmxName).stop();\n\t\t}\n\t\tcatch (InstanceNotFoundException ex) {\n\t\t\tthrow new MojoExecutionException(\n\t\t\t\t\t\"Spring application lifecycle JMX bean not found. Could not stop application gracefully\", ex);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":76,"sourceCodeEnd":100,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java#L76-L100","documentation":"In StopMojo.stop, calling SpringApplicationAdminClient.stop() throws InstanceNotFoundException when the lifecycle MBean is no longer registered under the expected objectName. The plugin cannot find the bean to invoke shutdown on, so it reports that it cannot stop the application gracefully.","triggerScenarios":"The application already exited, was never a Spring Boot app, or has spring.application.admin.enabled=false so the admin bean was never registered.","commonSituations":"Application crashed between spring-boot:start and spring-boot:stop; admin JMX disabled in the running app; start and stop mojos configured with different jmxName or jmxPort.","solutions":["Ensure spring.application.admin.enabled=true (or spring.boot.application.admin.enabled in older versions) in the app","Confirm the application is still running before invoking spring-boot:stop","Use matching jmxName and jmxPort between the start and stop goals"],"exampleFix":"// before\nspring.boot.application.admin.enabled: false\n// after\nspring.boot.application.admin.enabled: true","handlingStrategy":"validation","validationCode":"// Verify the lifecycle bean is registered before invoking stop\nSet<ObjectName> names = connection.queryNames(new javax.management.ObjectName(jmxName), null);\nif (names.isEmpty()) { /* bean already gone -- nothing to stop */ }","typeGuard":null,"tryCatchPattern":"try { new SpringApplicationAdminClient(connection, jmxName).stop(); } catch (InstanceNotFoundException ex) { log.warn(\"Lifecycle bean not registered -- application may have already exited\"); }","preventionTips":["Ensure spring.boot.application.admin.enabled=true in the running app","Confirm the application is still running before invoking spring-boot:stop","Use matching jmxName/jmxPort between start and stop goals"],"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"}