quarkusio/quarkus · error · GradleException

Failed to read

Error message

Failed to read 

What it means

DependencyUtils.getExtensionInfoOrNull inspects a resolved JAR artifact to detect a Quarkus extension by opening it as a zip filesystem and looking for META-INF/quarkus-extension.properties (BootstrapConstants.DESCRIPTOR_PATH). If the zip cannot be opened or read (corrupt jar, not a real zip, truncated download), the IOException is wrapped in a GradleException so the build fails loudly instead of silently skipping a possibly-misnamed extension JAR.

Source

Thrown at devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyUtils.java:129

        File artifactFile = artifact.getFile();
        if (!artifactFile.exists()) {
            return null;
        }

        if (artifactFile.isDirectory()) {
            Path descriptorPath = artifactFile.toPath().resolve(BootstrapConstants.DESCRIPTOR_PATH);
            if (Files.isRegularFile(descriptorPath)) {
                return createExtensionDependency(project, artifactId, descriptorPath);
            }
        } else if (ArtifactCoords.TYPE_JAR.equals(artifact.getExtension())) {
            try (FileSystem artifactFs = ZipUtils.newFileSystem(artifactFile.toPath())) {
                Path descriptorPath = artifactFs.getPath(BootstrapConstants.DESCRIPTOR_PATH);
                if (Files.exists(descriptorPath)) {
                    return createExtensionDependency(project, artifactId, descriptorPath);
                }
            } catch (IOException x) {
                throw new GradleException("Failed to read " + artifactFile, x);
            }
        }

        return null;
    }

    public static ExtensionDependency<?> getExtensionInfoOrNull(Project project, Project extensionProject) {
        boolean isIncludedBuild = !project.getRootProject().getGradle().equals(extensionProject.getRootProject().getGradle());

        ModuleVersionIdentifier extensionArtifactId = DefaultModuleVersionIdentifier.newId(
                extensionProject.getGroup().toString(),
                extensionProject.getName(),
                extensionProject.getVersion().toString());

        Object extensionConfiguration = extensionProject
                .getExtensions().findByName(ExtensionConstants.EXTENSION_CONFIGURATION_NAME);

        // If there's an extension configuration file in the project resources it can override

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the corrupted artifact from the local repository/cache and rebuild to re-download it (./gradlew --refresh-dependencies or rm the specific file)
  2. Verify the JAR integrity: unzip -t <file> or compare the SHA with the one published on Maven Central
  3. Check for disk-full or permission issues that could truncate writes to the cache
  4. If behind a proxy/firewall, confirm it is not serving HTML error pages saved as .jar
  5. Disable any artifact caching/mirroring layer (e.g. corporate Artifactory cache) temporarily to rule out a poisoned cache

Example fix

// before
$ ls ~/.gradle/caches/modules-2/files-2.1/com.example/ext-jar/.../ext-1.0.jar
# keep corrupted jar
// after
$ rm ~/.gradle/caches/modules-2/files-2.1/com.example/ext-jar -rf
$ ./gradlew build --refresh-dependencies
Defensive patterns

Strategy: try-catch

Validate before calling

File jar = artifact.getFile();
if (jar.length() == 0 || !jar.canRead()) throw new IllegalStateException("Bad artifact: " + jar);
// integrity probe
try (var zin = new java.util.zip.ZipFile(jar)) { if (zin.getEntry("META-INF/quarkus-extension.properties") == null) { /* not an ext */ } }
catch (java.util.zip.ZipException e) { throw new IllegalStateException("Corrupt jar: " + jar); }

Try / catch

try {
    var info = DependencyUtils.getExtensionInfoOrNull(artifact);
} catch (GradleException e) {
    if (e.getMessage().startsWith("Failed to read ")) {
        // delete the corrupt cached jar and refresh dependencies
        Files.deleteIfExists(artifact.getFile().toPath());
    } else throw e;
}

Prevention

When it happens

Trigger: A resolved dependency with .jar extension whose file cannot be opened as a zip archive — corrupted local repository entry, partially downloaded artifact, empty or non-zip file named .jar — during extension detection while collecting application dependencies.

Common situations: Interrupted downloads leaving a truncated JAR in ~/.m2/repository or ~/.gradle/caches/modules-2; a fork/relocated project producing an invalid jar; CI cache corruption; proxy intercepting downloads.

Related errors


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