quarkusio/quarkus · error · MojoExecutionException

Failed to transform native image agent configuration

Error message

Failed to transform native image agent configuration

What it means

NativeImageAgentMojo transforms the raw output of the native image tracing agent (config JSON files) into Quarkus-consumable configuration. If reading/writing those files throws an IOException, this MojoExecutionException is thrown.

Source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/NativeImageAgentMojo.java:93

                    Files.copy(basePath.resolve("jni-config.json"), targetPath.resolve("jni-config.json"),
                            StandardCopyOption.REPLACE_EXISTING);
                    Files.copy(basePath.resolve("proxy-config.json"), targetPath.resolve("proxy-config.json"),
                            StandardCopyOption.REPLACE_EXISTING);
                    transformJsonObject(basePath, "resource-config.json", targetPath,
                            JsonTransform.dropping(v -> discardResource("pattern", v)));

                    if (getLog().isInfoEnabled()) {
                        getLog().info("Discovered native image agent generated files in " + targetPath);
                    }
                } else {
                    final Path reflectOriginsTxtPath = basePath.resolve("reflect-origins.txt");
                    if (reflectOriginsTxtPath.toFile().exists()) {
                        getLog().info("Native image agent configuration origin files exist, inspect them manually inside "
                                + basePath);
                    }
                }
            } catch (IOException e) {
                throw new MojoExecutionException("Failed to transform native image agent configuration", e);
            }
        } else {
            getLog().debug("Missing " + dirName + " directory with native image agent configuration to transform");
        }
    }

    private void transformReachabilityMetadataJson(Path base, String name, Path target) throws IOException {
        getLog().debug("Discarding resources from native image configuration that match the following regular expression: "
                + resourceSkipPattern);
        final String original = Files.readString(base.resolve(name));
        final JsonObject jsonRead = JsonReader.of(original).read();
        JsonArray resources = jsonRead.get("resources");
        if (resources != null) {
            final JsonObjectBuilder jsonBuilder = Json.object();
            jsonBuilder.transform(jsonRead, JsonTransform.dropping(v -> discardResource("glob", v)));

            try (BufferedWriter writer = Files.newBufferedWriter(target.resolve(name))) {
                jsonBuilder.appendTo(writer);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the agent output directory (default target/native-image-agent-base) contains the expected JSON config files
  2. Fix read/write permissions on the directory and files
  3. Re-run the native tests with the agent attached to regenerate fresh output
  4. Check disk space and path validity
  5. Read the wrapped IOException for the exact file that failed

Example fix

// before
mvn quarkus:native-image-agent  # stale/partial agent output
// after
mvn clean && mvn -Pnative -Dquarkus.test.native-image-agent=... test && mvn quarkus:native-image-agent
Defensive patterns

Strategy: validation

Validate before calling

Path dir = Path.of("target", "native-image-agent-base");
if (Files.isDirectory(dir)) {
    try (var s = Files.list(dir)) {
        if (s.findAny().isEmpty()) throw new IllegalStateException("agent output dir empty; run agent-enabled tests first");
    }
}

Prevention

When it happens

Trigger: Running `mvn quarkus:native-image-agent` (or related goal) when the agent output directory exists but files are unreadable, unwritable, malformed paths, or output locations cannot be created.

Common situations: Agent output directory from a prior run has wrong permissions; target/ cleaned between runs; agent never ran so referenced files are missing; path too long on Windows.

Related errors


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