{"id":"1b019844f3270624","repo":"spring-projects/spring-boot","slug":"failed-to-connect-to-mbean-server-at-port","errorCode":null,"errorMessage":"Failed to connect to MBean server at port {}","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":155,"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":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java#L137-L173","documentation":"Error \"Failed to connect to MBean server at port {}\" thrown in spring-projects/spring-boot.","triggerScenarios":"Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java:155 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}