quarkusio/quarkus · error · CodeGenException

Failed to read resources from classpath

Error message

Failed to read resources from classpath

What it means

CodeGenException thrown by readConfig when consuming META-INF/services configuration service paths from the deployment classpath fails at the ClassPathUtils.consumeAsPaths level with an IOException. Unlike error 22 (a single file read failing), this means enumerating/opening the classpath resource itself failed, aborting configuration initialization for code generation.

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/CodeGenerator.java:328

            }
            log.warn(sb.toString());

            final Map<String, List<String>> allConfigServices = new HashMap<>(unavailableConfigServices.size());
            final Map<String, byte[]> allowedConfigServices = new HashMap<>(unavailableConfigServices.size());
            final Map<String, byte[]> bannedConfigServices = new HashMap<>(unavailableConfigServices.size());
            for (Map.Entry<String, List<String>> appModuleServices : unavailableConfigServices.entrySet()) {
                final String service = appModuleServices.getKey();
                try {
                    ClassPathUtils.consumeAsPaths(deploymentClassLoader, service, p -> {
                        try {
                            allConfigServices.computeIfAbsent(service, k -> new ArrayList<>())
                                    .addAll(Files.readAllLines(p));
                        } catch (IOException e) {
                            throw new UncheckedIOException("Failed to read " + p, e);
                        }
                    });
                } catch (IOException e) {
                    throw new CodeGenException("Failed to read resources from classpath", e);
                }
                final List<String> allServices = allConfigServices.getOrDefault(service, new ArrayList<>());
                allServices.removeAll(appModuleServices.getValue());
                if (allServices.isEmpty()) {
                    bannedConfigServices.put(service, new byte[0]);
                } else {
                    final StringJoiner joiner = new StringJoiner(System.lineSeparator());
                    allServices.forEach(joiner::add);
                    allowedConfigServices.put(service, joiner.toString().getBytes());
                }
            }

            // we don't want to load config services from the current module because they haven't been compiled yet
            final QuarkusClassLoader.Builder configClBuilder = QuarkusClassLoader.builder("CodeGenerator Config ClassLoader",
                    deploymentClassLoader, false);
            if (!allowedConfigServices.isEmpty()) {
                configClBuilder.addNormalPriorityElement(new MemoryClassPathElement(allowedConfigServices, true));
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Find and repair the offending classpath entry (usually a corrupt jar) — delete it from the local repository and rebuild
  2. Run a clean build so all classpath artifacts are regenerated
  3. Avoid concurrent builds/IDE syncs that mutate jars while Quarkus reads them
  4. Check filesystem health: permissions, disk space, symlink validity

Example fix

# before: jar being mutated during build (parallel builds)
mvn quarkus:build &
./build.sh  # overwrites jars concurrently
// after: run builds sequentially
mvn clean quarkus:build
Defensive patterns

Strategy: validation

Validate before calling

// Verify classpath jars are readable before invoking the build
for (Path jar : classpathJars) {
    if (!Files.isReadable(jar)) throw new IllegalStateException("Cannot read: " + jar);
    try (var fs = FileSystems.newFileSystem(jar, (ClassLoader) null)) { /* open ok */ }
}

Prevention

When it happens

Trigger: readConfig calls ClassPathUtils.consumeAsPaths(deploymentClassLoader, service, ...) to enumerate all copies of a config service file across classpath roots; any IOException thrown while walking those roots is caught and rethrown as 'Failed to read resources from classpath'.

Common situations: Corrupted jars on the build classpath; filesystem errors (permissions, disk full) while scanning the classpath; a jar changed or removed while the build was in progress (parallel build, IDE sync during build).

Related errors


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