{"record":{"id":"31a44ac9ef4baf2c","repo":"apache/maven","slug":"unable-to-load-the-mojo-mojodescriptor-getgoal-31a44a","errorCode":null,"errorMessage":"Unable to load the mojo '${mojoDescriptor.getGoal()}' in the plugin '${pluginDescriptor.getId()}' due to an API incompatibility: ${e.getClass().getName()}: ${cause.getMessage()}","messagePattern":"Unable to load the mojo '(.+?)' in the plugin '(.+?)' due to an API incompatibility: (.+?): (.+?)","errorType":"exception","errorClass":"PluginContainerException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java","lineNumber":717,"sourceCode":"\n            if ((cause instanceof NoClassDefFoundError) || (cause instanceof ClassNotFoundException)) {\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() + \"'. 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);","sourceCodeStart":699,"sourceCodeEnd":735,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L699-L735","documentation":"The mojo failed to load with a LinkageError that is not a missing class: NoSuchMethodError, NoSuchFieldError, AbstractMethodError, IllegalAccessError, VerifyError, and similar. The classes exist in the plugin realm but are binary-incompatible with what the plugin was compiled against, so DefaultMavenPluginManager throws PluginContainerException including the original error class, its message, and a dump of the plugin realm. This is almost always a wrong library version on the plugin classpath, not a code bug in your build.","triggerScenarios":"Dependency mediation inside the plugin realm selects an older/newer version of a library (Guava, commons-*, ASM, SLF4J) than the plugin requires; a library duplicated across plugin dependencies; plugin compiled against a JDK API not present in the JDK running Maven.","commonSituations":"Two plugins (or a plugin and its dependency) forcing different versions of the same library; upgrading one plugin while pinning a shared dependency; running a modern plugin on an EOL JDK; shaded plugins with duplicate classes.","solutions":["Read the message: the error class (e.g. NoSuchMethodError) names the missing member and its declaring class; search the realm dump for which artifact currently supplies that class.","Pin the version the plugin expects under <plugin><dependencies> so the realm resolves the compatible build.","Upgrade the plugin to a version aligned with the rest of your dependency stack.","Run mvn -X (debug) to see the exact realm composition and mediation decisions if the dump is ambiguous.","If the error mentions a JDK-internal class, move Maven itself onto the JDK the plugin requires."],"exampleFix":"// before: mediation pulls guava 19.0 into the realm, plugin compiled against 32.x -> NoSuchMethodError\n// after: pin the matching version inside the plugin block\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>com.google.guava</groupId>\n      <artifactId>guava</artifactId>\n      <version>32.1.3-jre</version>\n    </dependency>\n  </dependencies>\n</plugin>","handlingStrategy":"try-catch","validationCode":"# pre-flight: dump the resolved plugin classpath and look for unexpected versions of conflict-prone libraries\nmvn -X dependency:resolve-plugins 2>&1 | grep -E 'guava|commons-|asm' | sort -u","typeGuard":"static boolean binaryIncompatibleMojo(PluginContainerException e) {\n    Throwable c = e.getCause();\n    return c instanceof LinkageError && !(c instanceof NoClassDefFoundError);\n}","tryCatchPattern":"try {\n    Object mojo = pluginManager.getConfiguredMojo(mojoDescriptor, pluginRealm, session, mojoExecution);\n} catch (PluginContainerException e) {\n    if (e.getCause() instanceof LinkageError le && !(le instanceof NoClassDefFoundError)) {\n        // NoSuchMethodError/NoSuchFieldError/... : pin the conflicting library inside <plugin><dependencies>\n        reportVersionConflict(le);\n    }\n    throw e;\n}","preventionTips":["Declare critical shared libraries explicitly inside <plugin><dependencies> rather than relying on mediation.","Upgrade plugins together as a set so their shared dependency versions stay aligned.","Keep the JDK running Maven current enough for the newest plugin you use.","Watch Maven's 'duplicate declared dependency' style warnings during plugin resolution."],"tags":["maven","plugin","linkage-error","nosuchmethoderror","binary-incompatibility"],"backgroundTag":"class-version-conflict","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}