quarkusio/quarkus · error · IllegalStateException
Failed to locate resources.txt in the project's resources
Error message
Failed to locate resources.txt in the project's resources
What it means
This IllegalStateException is thrown by a Quarkus integration-test extension build step when the application archive does not contain a file named resources.txt at its root. The processor uses ApplicationArchivesBuildItem.getRootArchive().getChildPath("resources.txt") to locate the project's resources directory output; a null result means the test resource was not packaged into the app archive. It is a build-time assertion that the Gradle/Maven resource packaging worked as expected.
Source
Thrown at integration-tests/gradle/src/main/resources/test-resources-in-build-steps/deployment/src/main/java/org/acme/ext/deployment/AcmeExtProcessor.java:22
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
class AcmeExtProcessor {
private static final String FEATURE = "acme-ext";
@BuildStep
FeatureBuildItem feature(ApplicationArchivesBuildItem appArchivesBuildItem,
LaunchModeBuildItem launchModeBuildItem) {
Path p = appArchivesBuildItem.getRootArchive().getChildPath("resources.txt");
if(p == null) {
throw new IllegalStateException("Failed to locate resources.txt in the project's resources");
}
final Path output = p.getParent().getParent().getParent().resolve(launchModeBuildItem.getLaunchMode() + "-" + p.getFileName());
try {
Files.copy(p, output, StandardCopyOption.REPLACE_EXISTING);
} catch(IOException e) {
throw new IllegalStateException("Failed to copy " + p + " to " + output, e);
}
return new FeatureBuildItem(FEATURE);
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Add/restore resources.txt to the test project's src/main/resources directory
- Verify the Gradle build's sourceSets/resources configuration includes src/main/resources
- Run a clean build (./gradlew clean) to rule out stale incremental state
- Check that the correct project/module is being built and its archive is passed to the build step
Example fix
// before: file missing src/main/resources/resources.txt (absent) // after src/main/resources/resources.txt (create file with any content)
Defensive patterns
Strategy: validation
Validate before calling
Path p = appArchivesBuildItem.getRootArchive().getChildPath("resources.txt");
if (p == null) {
throw new IllegalStateException("resources.txt missing from app archive; check src/main/resources");
} Try / catch
try {
Files.copy(p, output, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new IllegalStateException("Failed to copy " + p + " to " + output, e);
} Prevention
- Keep required marker files in src/main/resources and commit them
- Run a clean build when resource packaging behavior changes
- Assert resource presence early in the build step with a clear message
When it happens
Trigger: Running the quarkus-gradle integration test when the test-resources-in-build-steps project's src/main/resources does not contain resources.txt, or when resource packaging/processing is skipped so the file is absent from the application archive root.
Common situations: Resource file renamed or deleted; Gradle processResources misconfigured or sourceSets changed; build running in a mode where the resources dir is not included in the archive (e.g. wrong module built); stale incremental build state.
Related errors
- Failed to copy " + p + " to " + output
- %s is marked @Record but does not inject an @Recorder object
- Cannot write service provider file '${resourceName}': this G
- One of either visitorFunction or inputTransformer must be se
- Use GeneratedServiceProviderBuildItem to register service pr
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/04c4223fbc298053.
Report an issue: GitHub.