spring-projects/spring-boot · error · MojoExecutionException

Shutdown failed

Error message

Shutdown failed

What it means

During stop(), invoking the 'shutdown' operation on the lifecycle MBean threw a ReflectionException, meaning the operation exists but its reflective invocation on the MBean failed. The cause is unwrapped (ex.getCause()) and surfaced as MojoExecutionException.

Solutions

  1. Inspect ex.getCause() for the real exception behind the reflection failure
  2. Review the application's shutdown logs for context-close errors
  3. If graceful stop is impossible, terminate the JVM directly and stop the goal
Defensive patterns

Strategy: try-catch

Try / catch

try { client.stop(); } catch (MojoExecutionException ex) { Throwable root = ex.getCause(); log.error("Shutdown reflected failure: {}", root); /* fall back to forced kill */ }

Prevention

When it happens

Trigger: The shutdown operation on the application's lifecycle MBean threw internally while being invoked reflectively.

Common situations: ApplicationContext.close() threw during shutdown; the MBean was unregistered between the existence check and the invoke; classloader issues during reflective call.

Related errors


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

Appendix: source

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

			throw new MojoExecutionException("Failed to retrieve Ready attribute", ex.getCause());
		}
		catch (MBeanException | IOException ex) {
			throw new MojoExecutionException(ex.getMessage(), ex);
		}
	}

	/**
	 * Stop the application managed by this instance.
	 * @throws MojoExecutionException if the JMX service could not be contacted
	 * @throws IOException if an I/O error occurs
	 * @throws InstanceNotFoundException if the lifecycle mbean cannot be found
	 */
	void stop() throws MojoExecutionException, IOException, InstanceNotFoundException {
		try {
			this.connection.invoke(this.objectName, "shutdown", null, null);
		}
		catch (ReflectionException ex) {
			throw new MojoExecutionException("Shutdown failed", ex.getCause());
		}
		catch (MBeanException ex) {
			throw new MojoExecutionException("Could not invoke shutdown operation", ex);
		}
	}

	private ObjectName toObjectName(String name) {
		try {
			return new ObjectName(name);
		}
		catch (MalformedObjectNameException ex) {
			throw new IllegalArgumentException("Invalid jmx name '" + name + "'");
		}
	}

	/**
	 * Create a connector for an {@link javax.management.MBeanServer} exposed on the
	 * current machine and the current port. Security should be disabled.

View on GitHub (pinned to 270dfe353f)