quarkusio/quarkus · error · RuntimeException
Failed to locate project's classes directory
Error message
Failed to locate project's classes directory
What it means
Thrown by QuarkusPluginExtension.appJarOrClasses() when it cannot determine the compiled classes directory: the jar archive file is absent/not built and QuarkusGradleUtils.getClassesDir() returns null for the main source set. Quarkus falls back to the classes directory when the jar isn't available, and failing both means it cannot locate application classes.
Source
Thrown at devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java:243
throw new RuntimeException("Failed to locate task 'jar' in the project.");
}
final Provider<RegularFile> jarProvider = jarTask.getArchiveFile();
Path classesDir = null;
if (jarProvider.isPresent()) {
final File f = jarProvider.get().getAsFile();
if (f.exists()) {
classesDir = f.toPath();
}
}
if (classesDir == null) {
final SourceSet mainSourceSet = getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
final String classesPath = QuarkusGradleUtils.getClassesDir(mainSourceSet, jarTask.getTemporaryDir(), false);
if (classesPath != null) {
classesDir = Paths.get(classesPath);
}
}
if (classesDir == null) {
throw new RuntimeException("Failed to locate project's classes directory");
}
return classesDir;
}
@SuppressWarnings("unused")
public MapProperty<String, String> getQuarkusBuildProperties() {
return quarkusBuildProperties;
}
public ListProperty<String> getCachingRelevantProperties() {
return cachingRelevantProperties;
}
public void set(String name, @Nullable String value) {
quarkusBuildProperties.put(addQuarkusBuildPropertyPrefix(name), value);
}
public void set(String name, Provider<String> value) {View on GitHub (pinned to e1c734241f)
Solutions
- Run a compile first (gradle classes) so the classes directory exists, then re-run the quarkus task
- Verify sourceSets.main.output.javaDirs/output dirs point to real directories; revert non-standard output customizations
- Check that the java plugin's main source set exists and isn't repurposed; configure quarkus tasks in the module containing the application sources
Example fix
// before
sourceSets.main.output.setGradleOutputDirs(listOf("build/custom-out"))
// after
sourceSets.main.output.setGradleOutputDirs(listOf("build/classes/java/main", "build/resources/main")) Defensive patterns
Strategy: validation
Validate before calling
def hasMainOutput(project: Project): Boolean =
project.extensions.getByType(SourceSetContainer::class.java)
.getByName("main").output.classesDirs.any { it.exists() } Type guard
def resolvableClassesDir(ss: SourceSet): Path? =
ss.output.classesDirs.firstOrNull { it.exists() }?.toPath() Try / catch
try { ext.appJarOrClasses() } catch (e: RuntimeException) {
if (e.message?.contains("Failed to locate project's classes directory") == true) {
throw IllegalStateException("Run 'gradle classes' first or fix sourceSets.main.output", e)
} else throw e
} Prevention
- Run 'gradle classes' before invoking quarkus tasks in CI
- Keep sourceSets.main.output at standard locations
- Verify source set customizations point to existing directories
When it happens
Trigger: Calling appJarOrClasses() when the project's main source set output/classes directory cannot be resolved (custom source set layout, non-standard output dirs, classes dir not yet created, or getClassesDir() misidentifying the output directory).
Common situations: Customized sourceSets.main.output directories; running quarkus tasks in a project whose classes were clean'd and jar disabled; multi-project setups where the main source set is unusual or the Kotlin/Java source dirs were moved.
Related errors
- Failed to process + artifactPath
- Failed to locate + pomPropsPath + on the classpath
- Failed to load + pomPropsPath + from the classpath
- Classpath resource + pomPropsPath + is missing groupId
- Classpath resource + pomPropsPath + is missing artifactId
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/3ec3417772603299.
Report an issue: GitHub.