spring-projects/spring-boot · error · MojoExecutionException
Failed to connect to MBean server at port {jmxPort}
Error message
Failed to connect to MBean server at port {jmxPort} What it means
Catch-all Exception handler in waitForSpringApplication for unexpected errors contacting the MBean server. Distinct from [48] which catches IOException specifically; this catches any other Throwable reaching the connection attempt.
Source
Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java:171
private void waitForSpringApplication() throws MojoFailureException, MojoExecutionException {
try {
getLog().debug("Connecting to local MBeanServer at port " + this.jmxPort);
try (JMXConnector connector = execute(this.wait, this.maxAttempts, new CreateJmxConnector(this.jmxPort))) {
if (connector == null) {
throw new MojoExecutionException("JMX MBean server was not reachable before the configured "
+ "timeout (" + (this.wait * this.maxAttempts) + "ms");
}
getLog().debug("Connected to local MBeanServer at port " + this.jmxPort);
MBeanServerConnection connection = connector.getMBeanServerConnection();
doWaitForSpringApplication(connection);
}
}
catch (IOException ex) {
throw new MojoFailureException("Could not contact Spring Boot application via JMX on port " + this.jmxPort
+ ". Please make sure that no other process is using that port", ex);
}
catch (Exception ex) {
throw new MojoExecutionException("Failed to connect to MBean server at port " + this.jmxPort, ex);
}
}
private void doWaitForSpringApplication(MBeanServerConnection connection)
throws MojoExecutionException, MojoFailureException {
final SpringApplicationAdminClient client = new SpringApplicationAdminClient(connection, this.jmxName);
try {
Callable<@Nullable Boolean> isReady = () -> (client.isReady() ? true : null);
execute(this.wait, this.maxAttempts, isReady);
}
catch (ReflectionException ex) {
throw new MojoExecutionException("Unable to retrieve 'ready' attribute", ex.getCause());
}
catch (Exception ex) {
throw new MojoFailureException("Could not invoke shutdown operation", ex);
}
}
View on GitHub (pinned to 270dfe353f)
Solutions
- Inspect the wrapped exception in the stack trace to identify the real class
- Confirm jmxPort and jmxName configuration match the running application
- Retry on a fresh port and re-run with mvn -X for verbose JMX diagnostics
Defensive patterns
Strategy: try-catch
Try / catch
try { waitForSpringApplication(); } catch (MojoExecutionException ex) { log.error("Unexpected JMX connection error on port {}", jmxPort, ex); throw ex; } Prevention
- Inspect the wrapped exception class to identify the real failure
- Confirm jmxPort and jmxName match the running application
- Re-run with mvn -X for verbose JMX diagnostics
When it happens
Trigger: Non-IO exception while establishing the MBean connection (e.g. runtime exception during connector construction, malformed JMX URL, NPE in client code).
Common situations: JMX client library version mismatch between plugin and JVM; malformed JMX service URL; unexpected null from connector factory.
Related errors
- Could not contact Spring Boot application via JMX on port {j
- Unexpected: attribute 'Ready' not available
- Failed to retrieve Ready attribute
- Shutdown failed
- Could not invoke shutdown operation
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/34c2fca877244501.
Report an issue: GitHub.