{"record":{"id":"20ca0f2df61db607","repo":"apache/maven","slug":"error-in-component-graph-of-plugin-plugin-getid","errorCode":null,"errorMessage":"Error in component graph of plugin ${plugin.getId()}: ${e.getMessage()}","messagePattern":"Error in component graph of plugin (.+?): (.+?)","errorType":"exception","errorClass":"PluginContainerException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java","lineNumber":457,"sourceCode":"            if (pluginDescriptor != null) {\n                for (MojoDescriptor mojo : pluginDescriptor.getMojos()) {\n                    if (!mojo.isV4Api()) {\n                        mojo.setRealm(pluginRealm);\n                        container.addComponentDescriptor(mojo);\n                    }\n                }\n            }\n\n            Thread.currentThread().setContextClassLoader(pluginRealm);\n            ((DefaultPlexusContainer) container)\n                    .discoverComponents(\n                            pluginRealm,\n                            new SessionScopeModule(container.lookup(SessionScope.class)),\n                            new MojoExecutionScopeModule(container.lookup(MojoExecutionScope.class)),\n                            new PluginConfigurationModule(plugin.getDelegate()),\n                            new SisuDiBridgeModule(true));\n        } catch (ComponentLookupException | CycleDetectedInComponentGraphException e) {\n            throw new PluginContainerException(\n                    plugin,\n                    pluginRealm,\n                    \"Error in component graph of plugin \" + plugin.getId() + \": \" + e.getMessage(),\n                    e);\n        } finally {\n            Thread.currentThread().setContextClassLoader(prevTccl);\n        }\n    }\n\n    private List<org.eclipse.aether.artifact.Artifact> toAetherArtifacts(final List<Artifact> pluginArtifacts) {\n        return new ArrayList<>(RepositoryUtils.toArtifacts(pluginArtifacts));\n    }\n\n    private List<Artifact> toMavenArtifacts(DependencyResult dependencyResult) {\n        return dependencyResult.getDependencyNodeResults().stream()\n                .filter(n -> n.getArtifact().getPath() != null)\n                .map(n -> RepositoryUtils.toArtifact(n.getDependency()))\n                .toList();","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L439-L475","documentation":"While setting up the plugin realm, Sisu/Plexus component discovery over the plugin's classes failed with ComponentLookupException or CycleDetectedInComponentGraphException: the plugin's components (discovered via annotations) form a dependency cycle or reference a component that cannot be satisfied. Maven wraps this in PluginContainerException naming the plugin and realm.","triggerScenarios":"Two components in the plugin inject each other directly or through a chain; a @Named/@Component role has no implementation available in the realm; plugin dependencies contribute extra plexus components that conflict or complete a cycle.","commonSituations":"Plugin refactors introducing mutually-dependent components; depending on another plugin's jar and doubling its components into the realm; constructor-injection cycles introduced while 'cleaning up' wiring.","solutions":["Read the message - the cycle path lists the components in the loop, or the lookup error names the missing role.","Break the cycle: inject Provider<T> or do a lazy lookup on one side of the loop instead of a direct reference.","Remove or exclude the plugin dependency that drags foreign components into the realm.","Upgrade the plugin - many component-graph issues are fixed upstream."],"exampleFix":"// before: cycle\n@Named class A { @Inject B b; }\n@Named class B { @Inject A a; }\n// after: break the cycle with a Provider\n@Named class A { @Inject B b; }\n@Named class B { private final Provider<A> a; @Inject B(Provider<A> a) { this.a = a; } }","handlingStrategy":"validation","validationCode":"// junit smoke test in the plugin's own build: fail on wiring problems at build time\n@Test void componentGraphIsAcyclic() throws Exception {\n    Injector injector = Guice.createInjector(\n        new WireModule(new ClassSpaceModule(new URLClassSpace(getClass().getClassLoader()))));\n    injector.getAllBindings(); // eager scan surfaces cycles/missing roles now, not in users' builds\n}","typeGuard":null,"tryCatchPattern":"try {\n    pluginManager.getConfiguredMojo(mojoInterface, session, mojoExecution);\n} catch (PluginContainerException e) {\n    Throwable c = e.getCause();\n    if (c instanceof CycleDetectedInComponentGraphException) {\n        // report the cycle path and the plugin id instead of failing the whole build silently\n        log.error(\"component cycle in {}: {}\", mojoExecution.getPlugin(), c.getMessage());\n    }\n    throw e;\n}","preventionTips":["Prefer constructor injection and break cycles with Provider<T>","Smoke-test component wiring in the plugin's unit tests","Never add another plugin's jar as a dependency of your plugin"],"tags":["maven","plugin","sisu","plexus","circular-dependency","dependency-injection"],"backgroundTag":"di-component-cycle","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}