quarkusio/quarkus · error · UncheckedIOException

Failed to read content of ${dep}

Error message

Failed to read content of ${dep}

What it means

collectNativeImageConfigRoots walks a dependency jar's entries to collect native-image configuration (native-image.properties, reflect-config.json, jni-config.json). If iterating the jar's entries throws an IOException — typically a corrupt or unreadable jar — it is wrapped in UncheckedIOException naming the dependency via toCompactCoords().

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarTreeShakeProcessor.java:237

        }
        for (NativeImageConfigBuildItem item : nativeImageConfigs) {
            for (String className : item.getRuntimeInitializedClasses()) {
                roots.produce(new JarTreeShakeRootClassBuildItem(className));
            }
        }

        for (ResolvedDependency dep : curateOutcome.getApplicationModel().getDependencies(DependencyFlags.RUNTIME_CP)) {
            try (OpenPathTree openTree = dep.getContentTree().open()) {
                openTree.walkIfContains(META_INF_NATIVE_IMAGE, visit -> {
                    String path = visit.getResourceName();
                    if (path.endsWith("native-image.properties")) {
                        parseNativeImageProperties(visit.getPath(), roots);
                    } else if (path.endsWith("reflect-config.json") || path.endsWith("jni-config.json")) {
                        parseJsonClassConfig(visit.getPath(), roots);
                    }
                });
            } catch (IOException e) {
                throw new UncheckedIOException("Failed to read content of " + dep.toCompactCoords(), e);
            }
        }
    }

    /**
     * Parses a {@code native-image.properties} file and extracts class names from
     * {@code --initialize-at-run-time}, {@code --initialize-at-build-time}, and
     * {@code --features} arguments.
     */
    private static void parseNativeImageProperties(java.nio.file.Path file,
            BuildProducer<JarTreeShakeRootClassBuildItem> roots) {
        try (BufferedReader reader = new BufferedReader(
                new InputStreamReader(Files.newInputStream(file), StandardCharsets.UTF_8))) {
            StringBuilder args = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.startsWith("#") || line.isEmpty()) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the named dependency from the local repository (~/.m2/repository/<group>/<artifact>) and rebuild with -U to re-download.
  2. Verify the jar with jar tf <file> — replace it if listing fails.
  3. Check file permissions/locks on the dependency jar path.
  4. If using SNAPSHOT dependencies, stop concurrent processes that rewrite them during the build.
  5. Disable/verify any proxy or mirror that could serve truncated artifacts.

Example fix

# before
rm -rf ~/.m2/repository/org/acme/broken-lib/1.0.0
# after
$ ./mvnw -U clean package  # re-downloads the dependency cleanly
Defensive patterns

Strategy: try-catch

Validate before calling

import java.util.jar.*;
import java.io.*;
File jar = new File("~/.m2/repository/.../dep-1.0.jar"); // path named in the error
try (JarFile jf = new JarFile(jar)) {
    // OK: jar readable
} catch (IOException e) {
    throw new IllegalStateException("Corrupt dependency jar — delete it from ~/.m2 and rebuild with -U", e);
}

Try / catch

try {
    // build with jar tree-shaking enabled
} catch (UncheckedIOException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Failed to read content of")) {
        // parse dep coords after 'Failed to read content of ', purge from ~/.m2, rebuild with -U
    } else throw e;
}

Prevention

When it happens

Trigger: Jar tree-shaking is enabled and the step visits a dependency whose jar file cannot be opened or streamed: corrupt download, zero-byte jar, unreadable file permissions, or a file replaced mid-read.

Common situations: Interrupted Maven downloads leaving truncated jars in ~/.m2; snapshot dependencies re-written while building; read-only or locked files on Windows; corrupted corporate-mirror artifacts.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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