apache/maven · error · PluginConfigurationException

Unable to find field '${resolution.getField()}' annotated wi

Error message

Unable to find field '${resolution.getField()}' annotated with @Resolution

What it means

The Maven-4 mojo descriptor records a @Resolution-annotated field by name, but no declared field with that name exists in the mojo class or any superclass - descriptor and bytecode disagree. Because the resolution cannot be injected into a nonexistent field, Maven throws PluginConfigurationException naming the missing field.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java:617

                mojo,
                mojoExecution.getExecutionId(),
                mojoDescriptor,
                pluginRealm,
                pomConfiguration,
                expressionEvaluator);

        for (Resolution resolution : mojoDescriptor.getMojoDescriptorV4().getResolutions()) {
            Field field = null;
            for (Class<?> clazz = mojo.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
                try {
                    field = clazz.getDeclaredField(resolution.getField());
                    break;
                } catch (NoSuchFieldException e) {
                    // continue
                }
            }
            if (field == null) {
                throw new PluginConfigurationException(
                        pluginDescriptor,
                        "Unable to find field '" + resolution.getField() + "' annotated with @Resolution");
            }
            field.setAccessible(true);
            String pathScope = resolution.getPathScope();
            Object result = null;
            if (pathScope != null && !pathScope.isEmpty()) {
                // resolution
                PathScope ps = sessionV4.getService(PathScopeRegistry.class).require(pathScope);
                DependencyResolverResult res =
                        sessionV4.getService(DependencyResolver.class).resolve(sessionV4, project, ps);
                if (field.getType() == DependencyResolverResult.class) {
                    result = res;
                } else if (field.getType() == Node.class) {
                    result = res.getRoot();
                } else if (field.getType() == List.class && field.getGenericType() instanceof ParameterizedType pt) {
                    Type t = pt.getActualTypeArguments()[0];
                    if (t == Node.class) {

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Clean-rebuild and reinstall the plugin: mvn clean install regenerates plugin.xml from the current annotations.
  2. Verify that every <resolution field="..."> in target/classes/META-INF/maven/plugin.xml matches a real field in the source.
  3. Keep maven-plugin-plugin aligned with the maven-plugin-annotations version used to compile.
  4. For a third-party plugin, report it or upgrade - the published descriptor is stale.

Example fix

// before: descriptor says field="deps" but the class now declares
@Resolution(DependencyScope.PROJECT)
private DependencyResolverResult resolutionResult;
// after: rename the field back to "deps", or regenerate the descriptor
mvn clean install -pl my-plugin
Defensive patterns

Strategy: validation

Validate before calling

mvn clean install -pl my-plugin
# descriptor fields must match every field carrying @Resolution in the sources:
grep -oE '<resolution field="[^"]+"' my-plugin/target/classes/META-INF/maven/plugin.xml

Try / catch

try {
    mojo = pluginManager.getConfiguredMojo(mojoInterface, session, mojoExecution);
} catch (PluginConfigurationException e) {
    if (e.getMessage() != null && e.getMessage().contains("annotated with @Resolution")) {
        // stale descriptor vs class: instruct users to take the freshly built plugin version
    }
    throw e;
}

Prevention

When it happens

Trigger: plugin.xml was generated from an older source of the mojo class (field renamed or removed since); a stale descriptor shipped by an incremental build; a descriptor hand-edited or produced by mismatched tooling.

Common situations: Plugin development with stale target/classes; renaming annotated fields without a clean rebuild; CI caches publishing plugins built from partial sources.

Related errors


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