{"record":{"id":"79d8d5faddaf78ae","repo":"apache/maven","slug":"unable-to-load-the-mojo-mojodescriptor-getgoal-79d8d5","errorCode":null,"errorMessage":"Unable to load the mojo '${mojoDescriptor.getGoal()}' (or one of its required components) from the plugin '${pluginDescriptor.getId()}'","messagePattern":"Unable to load the mojo '(.+?)' \\(or one of its required components\\) from the plugin '(.+?)'","errorType":"exception","errorClass":"PluginContainerException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java","lineNumber":720,"sourceCode":"                PrintStream ps = new PrintStream(os);\n                ps.println(\"Unable to load the mojo '\" + mojoDescriptor.getGoal() + \"' in the plugin '\"\n                        + pluginDescriptor.getId() + \"'. A required class is missing: \"\n                        + cause.getMessage());\n                pluginRealm.display(ps);\n\n                throw new PluginContainerException(mojoDescriptor, pluginRealm, os.toString(), cause);\n            } else if (cause instanceof LinkageError) {\n                ByteArrayOutputStream os = new ByteArrayOutputStream(1024);\n                PrintStream ps = new PrintStream(os);\n                ps.println(\"Unable to load the mojo '\" + mojoDescriptor.getGoal() + \"' in the plugin '\"\n                        + pluginDescriptor.getId() + \"' due to an API incompatibility: \"\n                        + e.getClass().getName() + \": \" + cause.getMessage());\n                pluginRealm.display(ps);\n\n                throw new PluginContainerException(mojoDescriptor, pluginRealm, os.toString(), cause);\n            }\n\n            throw new PluginContainerException(\n                    mojoDescriptor,\n                    pluginRealm,\n                    \"Unable to load the mojo '\" + mojoDescriptor.getGoal()\n                            + \"' (or one of its required components) from the plugin '\"\n                            + pluginDescriptor.getId() + \"'\",\n                    e);\n        }\n\n        if (mojo instanceof ContextEnabled contextEnabledMojo) {\n            MavenProject project = session.getCurrentProject();\n\n            Map<String, Object> pluginContext = session.getPluginContext(pluginDescriptor, project);\n\n            if (pluginContext != null) {\n                pluginContext.put(\"project\", project);\n\n                pluginContext.put(\"pluginDescriptor\", pluginDescriptor);\n","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L702-L738","documentation":"Catch-all branch when mojo instantiation failed without any LinkageError in the cause chain: the container (Plexus/Sisu) could not construct the mojo or wire its components. DefaultMavenPluginManager wraps the original exception in PluginContainerException, so the real reason (missing component, unsatisfied constructor argument, exception in constructor/static initializer) is in the cause, not the headline message.","triggerScenarios":"Mojo declares a @Component/@Inject field for a role that no artifact in the plugin realm registers; the mojo constructor or static initializer throws a RuntimeException; the plugin was packaged without its META-INF/plexus/components.xml or Sisu index, so its own components cannot be discovered.","commonSituations":"Hand-built or shaded plugin JARs that lose their component descriptors; plugin depending on a library version whose @Named implementations changed; mojos that do work in static blocks failing on unusual environments; incomplete plugin upgrades where a helper component moved artifacts.","solutions":["Re-run with mvn -e (and -X) and read the CAUSE stack trace below the PluginContainerException; it names the component or line that failed.","If a component lookup failed, add the artifact that provides (and indexes) that component as a dependency of the plugin.","If you own the plugin, verify the JAR packages META-INF/plexus/components.xml or META-INF/sisu/javax.inject.Named.","Check whether the plugin version matches the versions of the libraries it injects, and align them.","Report to the plugin project with the full stack if the plugin is unmodified third-party code."],"exampleFix":"// before: plugin needs a Sisu component that is not on its classpath\n<plugin>\n  <groupId>org.example</groupId>\n  <artifactId>example-maven-plugin</artifactId>\n  <version>1.0.0</version>\n</plugin>\n\n// after: add the artifact that provides (and indexes) the component\n<plugin>\n  <groupId>org.example</groupId>\n  <artifactId>example-maven-plugin</artifactId>\n  <version>1.0.0</version>\n  <dependencies>\n    <dependency>\n      <groupId>org.example</groupId>\n      <artifactId>example-spi</artifactId>\n      <version>1.4.0</version>\n    </dependency>\n  </dependencies>\n</plugin>","handlingStrategy":"try-catch","validationCode":"# pre-flight: prove the plugin and all its components load in an isolated build\nmvn -B -DskipTests verify -pl <module-using-plugin> -am\n# and smoke-test the goal directly with debug output\nmvn -X <goal-prefix>:<goal> | tail -100","typeGuard":"static boolean componentWiringFailure(PluginContainerException e) {\n    for (Throwable c = e.getCause(); c != null; c = c.getCause()) {\n        if (c instanceof LinkageError || c instanceof ClassNotFoundException) return false;\n    }\n    return true; // no linkage issue in the chain -> instantiation/DI problem\n}","tryCatchPattern":"try {\n    Object mojo = pluginManager.getConfiguredMojo(mojoDescriptor, pluginRealm, session, mojoExecution);\n} catch (PluginContainerException e) {\n    // the original failure (missing @Named component, ctor exception) is the cause chain\n    Throwable root = e;\n    while (root.getCause() != null) root = root.getCause();\n    reportMojoInstantiationFailure(mojoDescriptor.getGoal(), root);\n}","preventionTips":["For plugin authors: keep META-INF/sisu/javax.inject.Named in the shipped JAR so Sisu finds your components.","For plugin authors: unit-test mojo instantiation with org.apache.maven.plugin.testing.MojoRule.","For users: keep the plugin's dependency set intact; do not strip 'unused' jars.","When upgrading plugins, read release notes for moved/renamed components."],"tags":["maven","plugin","dependency-injection","sisu","plexus"],"backgroundTag":"component-injection-failure","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}