spring-projects/spring-boot · error · MojoExecutionException
JMX MBean server was not reachable before the configured…
Error message
JMX MBean server was not reachable before the configured timeout ({wait*maxAttempts}ms What it means
In StartMojo.waitForSpringApplication, the plugin attempts up to maxAttempts times (with wait ms between) to open a JMX connector to the spawned app via the CreateJmxConnector callback. If execute returns null after every attempt, the MBean server never became reachable in the configured window and the plugin aborts with MojoExecutionException naming the total budget (wait*maxAttempts ms).
Solutions
- Increase <configuration><wait> and/or <maxAttempts> so the budget exceeds worst-case startup
- Verify the remoteJmxArguments actually reach the spawned JVM (run with -X)
- Confirm nothing else is bound to the jmxPort and that the spawn produced a live process
Example fix
<!-- before --> <wait>500</wait><maxAttempts>20</maxAttempts> <!-- after --> <wait>1000</wait><maxAttempts>60</maxAttempts>
Defensive patterns
Strategy: retry
Validate before calling
// Confirm the port is free and the spawn produced a live process before waiting
try (java.net.ServerSocket s = new java.net.ServerSocket(jmxPort)) { /* port is free */ }
catch (IOException e) { /* port in use -- pick another */ } Try / catch
try { waitForSpringApplication(); } catch (MojoExecutionException ex) { log.error("JMX server not reachable within {}ms; raise <wait>/<maxAttempts>", wait*maxAttempts); throw ex; } Prevention
- Size wait*maxAttempts to exceed worst-case startup time
- Verify the remoteJmxArguments reach the spawned JVM with mvn -X
- Confirm the spawn produced a live process before waiting
When it happens
Trigger: Application started but never opened the JMX connector within wait*maxAttempts ms; spawn failed silently; jmxPort unreachable.
Common situations: Slow startup exceeding the configured budget; JVM args enabling remote JMX not propagated to the spawned process; security manager blocking RMI; misconfigured jmxPort.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Spring application did not start before the configured…
- Could not contact Spring Boot application via JMX on port
- Could not invoke shutdown operation
- Could not invoke shutdown operation
- Failed to connect to MBean server at port
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/da0dacd5820f6402.
Report an issue: GitHub.
Appendix: source
Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java:158
@Override
protected RunArguments resolveJvmArguments() {
RunArguments jvmArguments = super.resolveJvmArguments();
List<String> remoteJmxArguments = new ArrayList<>();
remoteJmxArguments.add("-Dcom.sun.management.jmxremote");
remoteJmxArguments.add("-Dcom.sun.management.jmxremote.port=" + this.jmxPort);
remoteJmxArguments.add("-Dcom.sun.management.jmxremote.authenticate=false");
remoteJmxArguments.add("-Dcom.sun.management.jmxremote.ssl=false");
remoteJmxArguments.add("-Djava.rmi.server.hostname=127.0.0.1");
jvmArguments.getArgs().addAll(remoteJmxArguments);
return jvmArguments;
}
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 {View on GitHub (pinned to 270dfe353f)