spring-projects/spring-boot · error · MojoFailureException

Could not contact Spring Boot application via JMX on port

Error message

Could not contact Spring Boot application via JMX on port {jmxPort}. Please make sure that no other process is using that port

What it means

IOException while communicating with the running Spring Boot app over JMX at jmxPort. Wrapped as MojoFailureException (a build failure, distinct from execution errors) and the message hints that another process may be using the port.

Solutions

  1. Pick a unique jmxPort per concurrent build: <configuration><jmxPort>9013</jmxPort></configuration>
  2. Confirm the application process is alive and listening on the jmxPort
  3. Disable parallel mvn runs that share a port, or assign jmxPort per build

Example fix

<!-- before -->
<!-- default jmxPort, shared across builds -->
<!-- after -->
<configuration><jmxPort>9013</jmxPort></configuration>
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the jmxPort is free before starting
try (java.net.ServerSocket s = new java.net.ServerSocket(jmxPort)) { /* free */ }
catch (IOException e) { throw new IllegalStateException("jmxPort " + jmxPort + " already in use", e); }

Try / catch

try { waitForSpringApplication(); } catch (MojoFailureException ex) { log.error("JMX IO failure on port {} -- likely a port conflict", jmxPort, ex); throw ex; }

Prevention

When it happens

Trigger: JMX connection broke mid-handshake, or could not be established at all due to a port conflict or RMI-level IO failure.

Common situations: Two concurrent builds sharing the same jmxPort; firewall/SELinux blocking localhost RMI; application crashed during the readiness handshake.

Related errors


AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11). Data as JSON: /api/errors/46b44afe65a313ff. Report an issue: GitHub.

Appendix: source

Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java:167

		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 {
		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) {

View on GitHub (pinned to 270dfe353f)