quarkusio/quarkus · error · RuntimeException

Failed to open class path file <file>

Error message

Failed to open class path file <file>

What it means

QuarkusCompiler.parseClassPath() walks the classpath entries and, while processing a classpath file, wraps any failure in a RuntimeException with 'Failed to open class path file <file>'. This indicates an entry in the dev mode classpath could not be read or opened (unreadable, deleted mid-scan, or a malformed path).

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/dev/QuarkusCompiler.java:175

                                File f;
                                // if it's a "file" scheme URI, then use the path as a file system path
                                // without the need to resolve it
                                if (cpEntryURI.isAbsolute() && cpEntryURI.getScheme().equals("file")) {
                                    f = new File(cpEntryURI.getPath());
                                } else {
                                    try {
                                        f = Paths.get(new URI("file", null, "/", null).resolve(cpEntryURI)).toFile();
                                    } catch (URISyntaxException e) {
                                        f = new File(file.getParentFile(), classPathEntry);
                                    }
                                }
                                if (f.exists()) {
                                    toParse.add(f.toPath());
                                }
                            }
                        }
                    } catch (Exception e) {
                        throw new RuntimeException("Failed to open class path file " + file, e);
                    }
                }
            }
        }
    }

    public void setupSourceCompilationContext(DevModeContext context,
            Set<File> classPathElements,
            Set<File> reloadableClassPathElements,
            DevModeContext.ModuleInfo i,
            DevModeContext.CompilationUnit compilationUnit, String name) {
        if (!compilationUnit.getSourcePaths().isEmpty()) {
            if (compilationUnit.getClassesPath() == null) {
                log.warn("No " + name + " directory found for module '" + i.getName()
                        + "'. It is advised that this module be compiled before launching dev mode");
                return;
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check the 'Caused by' exception to see why the file couldn't be opened (missing vs permission denied).
  2. Restore the missing artifact: run mvn install / gradle build for the missing dependency or module.
  3. Verify file permissions on the classpath file, especially on mounted volumes.
  4. Clean and restart dev mode so a fresh DevModeContext with valid paths is generated.

Example fix

// before: stale entry pointing to a deleted artifact
~/.m2/repository/com/example/lib/1.0/lib-1.0.jar  (missing)

// after
./mvnw install -pl lib  # rebuild/reinstall the artifact, then restart dev mode
Defensive patterns

Strategy: validation

Validate before calling

Path p = Path.of(classpathEntry);
if (!Files.isReadable(p)) throw new IllegalStateException("Unreadable classpath file: " + p);

Try / catch

try {
    // start dev mode
} catch (RuntimeException e) {
    if (e.getMessage().startsWith("Failed to open class path file")) {
        // rebuild the missing artifact or fix permissions, then restart
    }
}

Prevention

When it happens

Trigger: A JAR or classpath file referenced by the DevModeContext is missing, unreadable (permissions), or a directory/URL entry that throws while being iterated during compiler setup.

Common situations: Deleted or moved local Maven repository artifacts while dev mode runs; stale build outputs after branch switches; permission-restricted mounts (e.g. container volume or network drive).

Related errors


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