spring-projects/spring-boot · error · MojoExecutionException

Spring application lifecycle JMX bean not found. Could not…

Error message

Spring application lifecycle JMX bean not found. Could not stop application gracefully

What it means

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.

Solutions

  1. Ensure spring.application.admin.enabled=true (or spring.boot.application.admin.enabled in older versions) in the app
  2. Confirm the application is still running before invoking spring-boot:stop
  3. Use matching jmxName and jmxPort between the start and stop goals

Example fix

// before
spring.boot.application.admin.enabled: false
// after
spring.boot.application.admin.enabled: true
Defensive patterns

Strategy: validation

Validate before calling

// Verify the lifecycle bean is registered before invoking stop
Set<ObjectName> names = connection.queryNames(new javax.management.ObjectName(jmxName), null);
if (names.isEmpty()) { /* bean already gone -- nothing to stop */ }

Try / catch

try { new SpringApplicationAdminClient(connection, jmxName).stop(); } catch (InstanceNotFoundException ex) { log.warn("Lifecycle bean not registered -- application may have already exited"); }

Prevention

When it happens

Trigger: The application already exited, was never a Spring Boot app, or has spring.application.admin.enabled=false so the admin bean was never registered.

Common situations: 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.

Related errors


AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11). Data as JSON: /api/errors/aafe423162f84aee. Report an issue: GitHub.

Appendix: source

Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java:94

			return;
		}
		getLog().info("Stopping application...");
		try (JMXConnector connector = SpringApplicationAdminClient.connect(this.jmxPort)) {
			MBeanServerConnection connection = connector.getMBeanServerConnection();
			stop(connection);
		}
		catch (IOException ex) {
			// The response won't be received as the server has died - ignoring
			getLog().debug("Service is not reachable anymore (" + ex.getMessage() + ")");
		}
	}

	private void stop(MBeanServerConnection connection) throws IOException, MojoExecutionException {
		try {
			new SpringApplicationAdminClient(connection, this.jmxName).stop();
		}
		catch (InstanceNotFoundException ex) {
			throw new MojoExecutionException(
					"Spring application lifecycle JMX bean not found. Could not stop application gracefully", ex);
		}
	}

}

View on GitHub (pinned to 270dfe353f)