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

  1. Add/restore resources.txt to the test project's src/main/resources directory
  2. Verify the Gradle build's sourceSets/resources configuration includes src/main/resources
  3. Run a clean build (./gradlew clean) to rule out stale incremental state
  4. 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

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


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