quarkusio/quarkus · error · MojoExecutionException

Unable to write quarkus native image agent caller filter to

Error message

Unable to write quarkus native image agent caller filter to <path>

What it means

GenerateCodeTestsMojo.generateNativeAgentFilter writes a JSON caller-filter file used by the Quarkus native image agent. If BufferedWriter/appendTo throws IOException it wraps it in this MojoExecutionException naming the target path. The failure is purely about persisting the generated filter file to disk.

Solutions

  1. Ensure the parent directory of the filter file exists and is writable (e.g. `mvn quarkus:generate-code-tests` after a build creates target/)
  2. Check file permissions on the output path and that it is not a directory
  3. Free disk space / verify the path configured for the agent filter files is valid

Example fix

// before
mkdir target  # only if missing, before running
mvn quarkus:generate-code-tests
// after
mvn process-test-classes quarkus:generate-code-tests  # ensures target/ exists
Defensive patterns

Strategy: validation

Validate before calling

test -w <filter-file-dir> && test ! -d <filter-file> && df -h <filter-file-dir>

Try / catch

try {
    mvn quarkus:generate-code-tests
} catch (MojoExecutionException e) {
    // check the path named in the message: create parent dir / fix permissions
}

Prevention

When it happens

Trigger: Opening or writing path.toFile() with FileWriter(UTF-8) fails — e.g. the target directory does not exist, the path is a directory, or the process lacks write permission.

Common situations: target/ directory removed or read-only during CI; running `mvn quarkus:generate-code-tests` with -Dquarkus.test.native-image-agent-filter-files pointing to an unwritable/nonexistent location; disk-full conditions.

Understand the failure class

Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.

Related errors


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

Appendix: source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/GenerateCodeTestsMojo.java:104

    }

    private void generateNativeAgentFilter(Collection<String> packageNames, Path path) throws MojoExecutionException {
        final Json.JsonObjectBuilder result = Json.object();

        final Json.JsonArrayBuilder rules = Json.array();
        packageNames.stream()
                .map(packageName -> Json.object().put("excludeClasses", packageName + ".**"))
                .forEach(rules::add);
        result.put("rules", rules);

        final Json.JsonArrayBuilder regexRules = Json.array();
        regexRules.add(Json.object().put("excludeClasses", ".*_Bean"));
        result.put("regexRules", regexRules);

        try (BufferedWriter writer = new BufferedWriter(new FileWriter(path.toFile(), StandardCharsets.UTF_8))) {
            result.appendTo(writer);
        } catch (IOException e) {
            throw new MojoExecutionException("Unable to write quarkus native image agent caller filter to " + path, e);
        }
    }

    private Collection<ResolvedDependency> getDependencies() throws MojoExecutionException {
        try (CuratedApplication curatedApplication = bootstrapApplication(LaunchMode.TEST)) {
            return curatedApplication.getApplicationModel().getDependencies();
        } catch (Exception any) {
            throw new MojoExecutionException("Quarkus native image agent filter generation phase has failed", any);
        }
    }

    private Set<String> getCommonExcludePackageNames() {
        Set<String> packageNames = new HashSet<>();
        // Any calls that access or originate in these packages
        // that require native configuration should be handled by Quarkus.
        packageNames.add("io.netty");
        packageNames.add("io.quarkus");
        packageNames.add("io.smallrye");

View on GitHub (pinned to e1c734241f)