{"record":{"id":"cc5b2b7e1377c700","repo":"apache/maven","slug":"unable-to-inject-field-resolution-getfield","errorCode":null,"errorMessage":"Unable to inject field '${resolution.getField()}' annotated with @Dependencies. Unsupported type ${field.getGenericType()}","messagePattern":"Unable to inject field '(.+?)' annotated with @Dependencies\\. Unsupported type (.+?)","errorType":"exception","errorClass":"PluginConfigurationException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java","lineNumber":664,"sourceCode":"                            && ptv.getActualTypeArguments()[0] == Path.class) {\n                        result = res.getDispatchedPaths();\n                    } else if (k == Dependency.class && v == Path.class) {\n                        result = res.getDependencies();\n                    }\n                }\n            } else {\n                // collection\n                DependencyResolverResult res = sessionV4\n                        .getService(DependencyResolver.class)\n                        .collect(sessionV4, project, PathScope.MAIN_RUNTIME);\n                if (field.getType() == DependencyResolverResult.class) {\n                    result = res;\n                } else if (field.getType() == Node.class) {\n                    result = res.getRoot();\n                }\n            }\n            if (result == null) {\n                throw new PluginConfigurationException(\n                        pluginDescriptor,\n                        \"Unable to inject field '\" + resolution.getField()\n                                + \"' annotated with @Dependencies. Unsupported type \" + field.getGenericType());\n            }\n            try {\n                field.set(mojo, result);\n            } catch (IllegalAccessException e) {\n                throw new PluginConfigurationException(\n                        pluginDescriptor,\n                        \"Unable to inject field '\" + resolution.getField() + \"' annotated with @Dependencies\",\n                        e);\n            }\n        }\n\n        return mojo;\n    }\n\n    private <T> T loadV3Mojo(","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L646-L682","documentation":"For a @Dependencies-annotated field Maven performs dependency collection and then assigns the result only when the field type is DependencyResolverResult (or Node for the graph root); any other declared type leaves the result null, so Maven throws PluginConfigurationException naming the field and its unsupported generic type.","triggerScenarios":"Declaring the annotated field as List<Node>, Collection<Artifact>, Path, or any type other than DependencyResolverResult/Node - the injection machinery cannot map the collected graph onto it.","commonSituations":"Plugin developers adopting the Maven 4 @Dependencies annotation and guessing at collection types for the field.","solutions":["Change the field type to DependencyResolverResult for the full result, or Node for the collected graph root.","Derive whatever collection you need from result.getRoot().getChildren() or result.getDependencies() instead of asking the annotation for it.","Remove the annotation if you resolve dependencies yourself via the DependencyResolver service."],"exampleFix":"// before\n@Dependencies\nprivate List<Node> nodes;\n// after\n@Dependencies\nprivate DependencyResolverResult result;\n// then: result.getRoot().getChildren()","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean dependenciesFieldSupported(Field f) {\n    Class<?> t = f.getType();\n    return t == DependencyResolverResult.class || t == org.eclipse.aether.graph.Node.class;\n}","tryCatchPattern":"try {\n    mojo = pluginManager.getConfiguredMojo(mojoInterface, session, mojoExecution);\n} catch (PluginConfigurationException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"@Dependencies\")) {\n        // field type unsupported: switch to DependencyResolverResult/Node, then rebuild\n    }\n    throw e;\n}","preventionTips":["Check the @Dependencies javadoc for supported field types before declaring them","Add a reflection test asserting annotated fields use DependencyResolverResult or Node","Derive collections from result.getRoot().getChildren() instead of typing fields as lists"],"tags":["maven","maven4","dependencies-annotation","type-mismatch"],"backgroundTag":"unsupported-injection-type","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}