Skip to content
Latchkey

Maven Enforcer "Rule failed" / "Failed with message" - Fix in CI

The maven-enforcer-plugin failed the build because a project invariant it guards was violated - a banned or convergent dependency conflict, or a required Java/Maven version not met. This is a guardrail working as intended.

What this error means

The build fails (often in the validate phase) with Some Enforcer rules have failed and a specific rule name like DependencyConvergence, RequireJavaVersion, or BannedDependencies, plus the offending detail.

mvn output
[ERROR] Rule 1: org.apache.maven.enforcer.rules.dependency.DependencyConvergence
failed with message:
Failed while enforcing releasability.
Dependency convergence error for com.fasterxml.jackson.core:jackson-databind:
2.15.0 paths to dependency are: ...
[ERROR] Some Enforcer rules have failed.

Common causes

Conflicting transitive versions (convergence)

Two paths pull different versions of the same dependency. DependencyConvergence fails the build until you pin one version.

Banned dependency or unmet version requirement

A BannedDependencies rule hit a forbidden artifact, or RequireJavaVersion/RequireMavenVersion found the running toolchain below the required floor.

How to fix it

Converge the conflicting dependency

Pin the conflicting library to one version via dependencyManagement so all paths agree.

pom.xml
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.17.1</version>
    </dependency>
  </dependencies>
</dependencyManagement>

Meet the required version or remove the banned dep

  1. For RequireJavaVersion, provision the required JDK in CI with setup-java.
  2. For BannedDependencies, replace or exclude the forbidden artifact.
  3. Inspect conflicts with mvn dependency:tree -Dverbose before changing versions.

How to prevent it

  • Manage versions centrally in dependencyManagement so convergence holds.
  • Run mvn dependency:tree -Dverbose to find conflicting paths early.
  • Treat enforcer failures as real violations, not noise to suppress.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →