{"record":{"id":"da0dacd5820f6402","repo":"spring-projects/spring-boot","slug":"jmx-mbean-server-was-not-reachable-before-the-conf","errorCode":null,"errorMessage":"JMX MBean server was not reachable before the configured timeout ({wait*maxAttempts}ms","messagePattern":"JMX MBean server was not reachable before the configured timeout \\((.+?)ms","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java","lineNumber":158,"sourceCode":"\t@Override\n\tprotected RunArguments resolveJvmArguments() {\n\t\tRunArguments jvmArguments = super.resolveJvmArguments();\n\t\tList<String> remoteJmxArguments = new ArrayList<>();\n\t\tremoteJmxArguments.add(\"-Dcom.sun.management.jmxremote\");\n\t\tremoteJmxArguments.add(\"-Dcom.sun.management.jmxremote.port=\" + this.jmxPort);\n\t\tremoteJmxArguments.add(\"-Dcom.sun.management.jmxremote.authenticate=false\");\n\t\tremoteJmxArguments.add(\"-Dcom.sun.management.jmxremote.ssl=false\");\n\t\tremoteJmxArguments.add(\"-Djava.rmi.server.hostname=127.0.0.1\");\n\t\tjvmArguments.getArgs().addAll(remoteJmxArguments);\n\t\treturn jvmArguments;\n\t}\n\n\tprivate void waitForSpringApplication() throws MojoFailureException, MojoExecutionException {\n\t\ttry {\n\t\t\tgetLog().debug(\"Connecting to local MBeanServer at port \" + this.jmxPort);\n\t\t\ttry (JMXConnector connector = execute(this.wait, this.maxAttempts, new CreateJmxConnector(this.jmxPort))) {\n\t\t\t\tif (connector == null) {\n\t\t\t\t\tthrow new MojoExecutionException(\"JMX MBean server was not reachable before the configured \"\n\t\t\t\t\t\t\t+ \"timeout (\" + (this.wait * this.maxAttempts) + \"ms\");\n\t\t\t\t}\n\t\t\t\tgetLog().debug(\"Connected to local MBeanServer at port \" + this.jmxPort);\n\t\t\t\tMBeanServerConnection connection = connector.getMBeanServerConnection();\n\t\t\t\tdoWaitForSpringApplication(connection);\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new MojoFailureException(\"Could not contact Spring Boot application via JMX on port \" + this.jmxPort\n\t\t\t\t\t+ \". Please make sure that no other process is using that port\", ex);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new MojoExecutionException(\"Failed to connect to MBean server at port \" + this.jmxPort, ex);\n\t\t}\n\t}\n\n\tprivate void doWaitForSpringApplication(MBeanServerConnection connection)\n\t\t\tthrows MojoExecutionException, MojoFailureException {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java#L140-L176","documentation":"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).","triggerScenarios":"Application started but never opened the JMX connector within wait*maxAttempts ms; spawn failed silently; jmxPort unreachable.","commonSituations":"Slow startup exceeding the configured budget; JVM args enabling remote JMX not propagated to the spawned process; security manager blocking RMI; misconfigured jmxPort.","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"],"exampleFix":"<!-- before -->\n<wait>500</wait><maxAttempts>20</maxAttempts>\n<!-- after -->\n<wait>1000</wait><maxAttempts>60</maxAttempts>","handlingStrategy":"retry","validationCode":"// Confirm the port is free and the spawn produced a live process before waiting\ntry (java.net.ServerSocket s = new java.net.ServerSocket(jmxPort)) { /* port is free */ }\ncatch (IOException e) { /* port in use -- pick another */ }","typeGuard":null,"tryCatchPattern":"try { waitForSpringApplication(); } catch (MojoExecutionException ex) { log.error(\"JMX server not reachable within {}ms; raise <wait>/<maxAttempts>\", wait*maxAttempts); throw ex; }","preventionTips":["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"],"tags":["jmx","startup","maven-plugin","timeout"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}