apache/maven · error · ConflictResolverNotFoundException

Cannot find conflict resolver of type: " + type

Error message

Cannot find conflict resolver of type: " + type

What it means

DefaultConflictResolverFactory.getConflictResolver(type) performs a Plexus component lookup of the ConflictResolver role with the given hint. When the lookup throws ComponentLookupException (no component registered under that hint), it is converted to ConflictResolverNotFoundException('Cannot find conflict resolver of type: <type>'). The registered legacy implementations are 'nearest', 'newest', 'oldest' and 'farthest'.

Source

Thrown at compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolverFactory.java:61

    /**
     * The plexus container used to obtain instances from.
     */
    @Inject
    private PlexusContainer container;

    // ConflictResolverFactory methods ----------------------------------------

    /*
     * @see org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory#getConflictResolver(java.lang.String)
     */

    @Override
    public ConflictResolver getConflictResolver(String type) throws ConflictResolverNotFoundException {
        try {
            return (ConflictResolver) container.lookup(ConflictResolver.ROLE, type);
        } catch (ComponentLookupException exception) {
            throw new ConflictResolverNotFoundException("Cannot find conflict resolver of type: " + type);
        }
    }

    // Contextualizable methods -----------------------------------------------

    /*
     * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
     */

    @Override
    public void contextualize(Context context) throws ContextException {
        container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Use one of the built-in type hints: "nearest" (Maven default), "newest", "oldest", or "farthest" — exact lowercase spelling
  2. If a custom ConflictResolver is intended, ensure it is a proper Plexus/JSR-330 component with a component descriptor on the runtime classpath
  3. Clear or correct the property/configuration that carries the resolver type (it was commonly injected via system property in Maven 2 forks)

Example fix

// before
ConflictResolver r = factory.getConflictResolver("Nearest");

// after
ConflictResolver r = factory.getConflictResolver("nearest");
Defensive patterns

Strategy: validation

Validate before calling

private static final Set<String> KNOWN_CONFLICT_RESOLVERS =
    Set.of("nearest", "newest", "oldest", "farthest");

String normalizeConflictResolverType(String type) {
    String t = type == null ? "nearest" : type.trim().toLowerCase(Locale.ROOT);
    if (!KNOWN_CONFLICT_RESOLVERS.contains(t)) {
        throw new IllegalArgumentException(
            "Unknown conflict resolver '" + type + "'; expected one of " + KNOWN_CONFLICT_RESOLVERS);
    }
    return t;
}

Try / catch

try {
    ConflictResolver resolver = factory.getConflictResolver(type);
} catch (ConflictResolverNotFoundException e) {
    log.warn("Unknown conflict resolver type '{}'; using 'nearest'", type);
    resolver = factory.getConflictResolver("nearest");
}

Prevention

When it happens

Trigger: Passing a conflict resolver type string that has no registered component — a typo ('newest ' with whitespace, 'Nearest' wrong case, 'nearest-version') or a custom type whose implementation class was removed from the classpath. Reached through the legacy resolver when it asks the factory for the configured conflict resolution strategy.

Common situations: Porting Maven 2-era configuration or documentation that references a conflict resolver name that no longer exists; custom Plexus component not discovered because its JAR lacks proper metadata; classpath pruning (maven-shade/assembly) stripping the component descriptor.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/8e44c5bda24800e2. Report an issue: GitHub.