{"record":{"id":"e5e4e9452bab79d6","repo":"apache/maven","slug":"unable-to-load-the-mojo-mojodescriptor-getgoal","errorCode":null,"errorMessage":"Unable to load the mojo '${mojoDescriptor.getGoal()}' in the plugin '${pluginDescriptor.getId()}'. A required class is missing: ${cause.getMessage()}","messagePattern":"Unable to load the mojo '(.+?)' in the plugin '(.+?)'\\. A required class is missing: (.+?)","errorType":"exception","errorClass":"PluginContainerException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java","lineNumber":708,"sourceCode":"        T mojo;\n\n        try {\n            mojo = container.lookup(mojoInterface, mojoDescriptor.getRoleHint());\n        } catch (ComponentLookupException e) {\n            Throwable cause = e.getCause();\n            while (cause != null && !(cause instanceof LinkageError) && !(cause instanceof ClassNotFoundException)) {\n                cause = cause.getCause();\n            }\n\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);","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L690-L726","documentation":"Maven built the plugin's class realm but could not load the mojo class because a class it references is absent from that realm. DefaultMavenPluginManager walks the cause chain to the first NoClassDefFoundError/ClassNotFoundException and throws PluginContainerException, appending a dump of every jar/URL in the plugin realm so you can see which artifact should have supplied the missing class. The class name after 'A required class is missing:' is the key diagnostic.","triggerScenarios":"Calling mojo execution (direct goal invocation, lifecycle phase, or embedder getConfiguredMojo) when the plugin realm lacks a jar: a blanket <exclusions> on the plugin or its dependency, dependency mediation dropping a transitive jar, an optional/provided dependency that is not present, or a corrupted/zero-byte jar in the local repository.","commonSituations":"Copy-pasted <exclusions> with groupId/artifactId wildcards in pluginManagement; interrupted downloads leaving broken jars in ~/.m2/repository; running with -o (offline) against a partially cached plugin; plugin version expecting a library that a pinned older dependency shadows.","solutions":["Read the realm dump in the message: find the class named after 'A required class is missing:' and check which artifact in the dump (or missing from it) should contain it.","Delete the suspect artifact directory under ~/.m2/repository and rebuild with mvn -U so it is re-downloaded and checksum-verified.","Remove or narrow <exclusions> declared on the plugin (or its parent pluginManagement) so the required transitive jar returns to the realm.","Pin the correct version of the missing library under <plugin><dependencies> if another plugin dependency pulls an incompatible subset.","Upgrade or downgrade the plugin to a version whose dependency set resolves cleanly in your environment."],"exampleFix":"// before: blanket exclusion strips a jar the mojo needs\n<plugin>\n  <groupId>org.example</groupId>\n  <artifactId>example-maven-plugin</artifactId>\n  <version>1.2.0</version>\n  <dependencies>\n    <dependency>\n      <groupId>org.example</groupId>\n      <artifactId>example-spi</artifactId>\n      <version>1.4.0</version>\n      <exclusions>\n        <exclusion><groupId>*</groupId><artifactId>*</artifactId></exclusion>\n      </exclusions>\n    </dependency>\n  </dependencies>\n</plugin>\n\n// after: drop the wildcard exclusion so the missing class is back on the plugin classpath\n<plugin>\n  <groupId>org.example</groupId>\n  <artifactId>example-maven-plugin</artifactId>\n  <version>1.2.0</version>\n</plugin>","handlingStrategy":"try-catch","validationCode":"# pre-flight: force full plugin resolution and drop zero-byte stubs before the real build\nmvn -B dependency:resolve-plugins\nfind ~/.m2/repository -name '*.jar' -size -1b -print -delete\nmvn -U verify","typeGuard":"static boolean missingClassInMojoRealm(PluginContainerException e) {\n    Throwable c = e.getCause();\n    return c instanceof NoClassDefFoundError || c instanceof ClassNotFoundException;\n}","tryCatchPattern":"try {\n    Object mojo = pluginManager.getConfiguredMojo(mojoDescriptor, pluginRealm, session, mojoExecution);\n} catch (PluginContainerException e) {\n    Throwable c = e.getCause();\n    if (c instanceof NoClassDefFoundError || c instanceof ClassNotFoundException) {\n        // classpath hole: e.getMessage() already embeds the plugin realm dump\n        reportPluginClasspathHole(e);\n    }\n    throw e;\n}","preventionTips":["Pin explicit versions for every plugin so the realm composition is reproducible.","Never use wildcard <exclusions> on plugin dependencies; exclude one artifact at a time.","Run CI builds against a pristine local repository so corrupt jars surface immediately.","After interrupted downloads, clean the affected group under ~/.m2/repository before the next build."],"tags":["maven","plugin","classpath","noclassdeffounderror","classnotfoundexception"],"backgroundTag":"missing-class-classpath","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}