{"record":{"id":"34c2fca877244501","repo":"spring-projects/spring-boot","slug":"failed-to-connect-to-mbean-server-at-port-jmxport","errorCode":null,"errorMessage":"Failed to connect to MBean server at port {jmxPort}","messagePattern":"Failed to connect to MBean server at port (.+?)","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":171,"sourceCode":"\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 {\n\t\tfinal SpringApplicationAdminClient client = new SpringApplicationAdminClient(connection, this.jmxName);\n\t\ttry {\n\t\t\tCallable<@Nullable Boolean> isReady = () -> (client.isReady() ? true : null);\n\t\t\texecute(this.wait, this.maxAttempts, isReady);\n\t\t}\n\t\tcatch (ReflectionException ex) {\n\t\t\tthrow new MojoExecutionException(\"Unable to retrieve 'ready' attribute\", ex.getCause());\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new MojoFailureException(\"Could not invoke shutdown operation\", ex);\n\t\t}\n\t}\n","sourceCodeStart":153,"sourceCodeEnd":189,"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#L153-L189","documentation":"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.","triggerScenarios":"Non-IO exception while establishing the MBean connection (e.g. runtime exception during connector construction, malformed JMX URL, NPE in client code).","commonSituations":"JMX client library version mismatch between plugin and JVM; malformed JMX service URL; unexpected null from connector factory.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { waitForSpringApplication(); } catch (MojoExecutionException ex) { log.error(\"Unexpected JMX connection error on port {}\", jmxPort, ex); throw ex; }","preventionTips":["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"],"tags":["jmx","networking","maven-plugin"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}