{"record":{"id":"490c8dcea4ff88b5","repo":"apache/maven","slug":"cannot-setup-plugin-realm-mojodescriptor-mojode","errorCode":null,"errorMessage":"Cannot setup plugin realm [mojoDescriptor=${mojoDescriptor.getId()}, pluginDescriptor=${pluginDescriptor.getId()}]","messagePattern":"Cannot setup plugin realm \\[mojoDescriptor=(.+?), pluginDescriptor=(.+?)\\]","errorType":"exception","errorClass":"PluginConfigurationException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java","lineNumber":514,"sourceCode":"        return foreignImports;\n    }\n\n    @Override\n    public <T> T getConfiguredMojo(Class<T> mojoInterface, MavenSession session, MojoExecution mojoExecution)\n            throws PluginConfigurationException, PluginContainerException {\n        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();\n\n        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();\n\n        ClassRealm pluginRealm = pluginDescriptor.getClassRealm();\n\n        if (pluginRealm == null) {\n            try {\n                setupPluginRealm(pluginDescriptor, session, null, null, null);\n            } catch (PluginResolutionException e) {\n                String msg = \"Cannot setup plugin realm [mojoDescriptor=\" + mojoDescriptor.getId()\n                        + \", pluginDescriptor=\" + pluginDescriptor.getId() + \"]\";\n                throw new PluginConfigurationException(pluginDescriptor, msg, e);\n            }\n            pluginRealm = pluginDescriptor.getClassRealm();\n        }\n\n        if (logger.isDebugEnabled()) {\n            logger.debug(\"Loading mojo \" + mojoDescriptor.getId() + \" from plugin realm \" + pluginRealm);\n        }\n\n        // We are forcing the use of the plugin realm for all lookups that might occur during\n        // the lifecycle that is part of the lookup. Here we are specifically trying to keep\n        // lookups that occur in contextualize calls in line with the right realm.\n        ClassRealm oldLookupRealm = container.setLookupRealm(pluginRealm);\n\n        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();\n        Thread.currentThread().setContextClassLoader(pluginRealm);\n\n        try {\n            if (mojoDescriptor.isV4Api()) {","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L496-L532","documentation":"When a mojo is configured, Maven lazily builds the plugin realm if it does not exist yet; if resolving the plugin's own dependencies fails (PluginResolutionException - artifact missing, unreachable, or version unresolvable), it is rethrown as PluginConfigurationException 'Cannot setup plugin realm [mojoDescriptor=..., pluginDescriptor=...]' and the build fails.","triggerScenarios":"Plugin dependencies cannot be downloaded: the hosting repository is not configured as a <pluginRepository>, offline mode (-o) runs against a cold local repository, a version range resolves to nothing, or the artifact was removed from the remote.","commonSituations":"Air-gapped/offline builds; corporate mirrors lagging new plugin releases; snapshots not resolved because repository policies disable snapshot updates; version numbers typed by hand.","solutions":["Inspect the cause (PluginResolutionException) - it names exactly which artifact failed and why.","Add or fix the <pluginRepository> entry hosting the plugin's dependencies; plugin artifacts resolve only from plugin repositories.","If offline, first run an offline-preparation build (go-offline-maven-plugin) or drop -o for one full pass.","Delete the failing artifact's folder in the local repository and rebuild with -U."],"exampleFix":"<!-- before: dependency available only in <repositories> -->\n<!-- after: also declare it where plugins can resolve it -->\n<pluginRepositories>\n  <pluginRepository>\n    <id>corp-plugins</id>\n    <url>https://nexus.corp/repo/plugins</url>\n  </pluginRepository>\n</pluginRepositories>","handlingStrategy":"validation","validationCode":"mvn -q de.qaware.maven:go-offline-maven-plugin:2.10.0:resolve-dependencies \\\n  || { echo 'plugin classpath not fully resolvable - fix before offline build'; exit 1; }","typeGuard":null,"tryCatchPattern":"try {\n    mojo = pluginManager.getConfiguredMojo(mojoInterface, session, mojoExecution);\n} catch (PluginConfigurationException e) {\n    if (e.getCause() instanceof PluginResolutionException) {\n        // name the unresolvable artifact and repo so users know it is a fetch problem, not code\n        log.error(\"unresolved plugin dependency: {}\", e.getCause().getMessage());\n    }\n    throw e;\n}","preventionTips":["Keep <pluginRepositories> in sync with <repositories> for anything plugins need","Prepare offline caches with go-offline-maven-plugin before switching to -o builds","Pin exact plugin versions so resolution is deterministic"],"tags":["maven","plugin","resolution","repository","offline"],"backgroundTag":"plugin-artifact-resolution-failure","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}