quarkusio/quarkus · error · MojoExecutionException

Failed to resolve maven plugin version containing <cls>

Error message

Failed to resolve maven plugin version containing <cls>

What it means

CreateUtils.resolvePluginInfo locates the running Quarkus Maven plugin's own descriptor (META-INF/maven/plugin.xml) either next to the class (exploded dir) or inside its jar via ZipUtils.newFileSystem. Any exception while locating/opening the class origin or reading the descriptor is rethrown as this MojoExecutionException naming the class. It is used to discover the plugin version for invoking nested goals like create/add-extension in the generated project.

Source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/CreateUtils.java:51

    }

    public static String getDerivedPath(String className) {
        String[] resourceClassName = StringUtils.splitByCharacterTypeCamelCase(
                className.substring(className.lastIndexOf(".") + 1));
        return "/" + resourceClassName[0].toLowerCase();
    }

    public static Plugin resolvePluginInfo(Class<?> cls) throws MojoExecutionException {
        try {
            final Path classOrigin = MojoUtils.getClassOrigin(cls);
            if (Files.isDirectory(classOrigin)) {
                return resolvePluginInfo(classOrigin.resolve("META-INF").resolve("maven").resolve("plugin.xml"));
            }
            try (FileSystem fs = ZipUtils.newFileSystem(classOrigin)) {
                return resolvePluginInfo(fs.getPath("META-INF", "maven", "plugin.xml"));
            }
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to resolve maven plugin version containing " + cls, e);
        }
    }

    private static Plugin resolvePluginInfo(Path pluginXml) throws MojoExecutionException {
        if (!Files.exists(pluginXml)) {
            throw new MojoExecutionException("Failed to locate " + pluginXml);
        }
        final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        try {
            final DocumentBuilder db = dbf.newDocumentBuilder();
            try (InputStream is = Files.newInputStream(pluginXml)) {
                final Document doc = db.parse(is);
                final Node pluginNode = getElement(doc.getChildNodes(), "plugin");
                final Plugin plugin = new Plugin();
                plugin.setGroupId(getChildElementTextValue(pluginNode, "groupId"));
                plugin.setArtifactId(getChildElementTextValue(pluginNode, "artifactId"));
                plugin.setVersion(getChildElementTextValue(pluginNode, "version"));
                return plugin;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the quarkus-maven-plugin artifacts under ~/.m2/repository/io/quarkus/quarkus-maven-plugin and let Maven re-download them
  2. Run with `mvn -U` to force re-resolution of plugin artifacts
  3. Verify exactly one version of quarkus-maven-plugin is used (check pluginManagement/dependency convergence)
  4. Inspect the 'Caused by' exception for the underlying zip/file-system error

Example fix

# corrupted local artifact
rm -rf ~/.m2/repository/io/quarkus/quarkus-maven-plugin
mvn -U io.quarkus:quarkus-maven-plugin:create
Defensive patterns

Strategy: try-catch

Validate before calling

# Verify the plugin jar is a valid zip before running goals
unzip -tq $(find ~/.m2/repository/io/quarkus/quarkus-maven-plugin -name '*.jar' | head -1) > /dev/null && echo OK

Try / catch

try {
    Plugin p = resolvePluginInfo(cls);
} catch (MojoExecutionException e) {
    // inspect cause: ZipException => corrupted jar; delete and re-resolve the artifact
    logger.error("Plugin descriptor resolution failed: " + e.getCause(), e);
}

Prevention

When it happens

Trigger: Calling createUtils-based goal invocation where the JAR containing the plugin class cannot be opened as a zip (corrupted download), the class origin path cannot be determined, or an unexpected I/O error occurs accessing META-INF/maven/plugin.xml.

Common situations: Corrupted ~/.m2 repository entry for quarkus-maven-plugin (interrupted download); running plugin classes from an unusual classloader/custom setup where classOrigin resolution fails; mixed plugin versions on the classpath.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/da2da6f326c1e63f. Report an issue: GitHub.