quarkusio/quarkus · error · UncheckedIOException

Unable to copy json config file from

Error message

Unable to copy json config file from ${jsonPath} to ${thinJarDirectory}

What it means

NativeImageSourceJarBuilder wraps an IOException in an UncheckedIOException when copying a native-image JSON config file (e.g. from native-image properties/config) into the thin jar directory fails. The copy creates the thinJarDirectory then copies the JSON file, and any filesystem failure is rethrown with this descriptive message.

Solutions

  1. Check file permissions on the source JSON file and the target build directory and ensure they are readable/writable.
  2. Verify the jsonPath file exists (not deleted between configuration and packaging) and is a regular file.
  3. Free disk space and run ./mvnw clean, then rebuild the native image source jar.

Example fix

// before (config file missing)
quarkus.native.additional-build-args=-H:ResourceConfigurationFiles=missing.json
// after (ensure file exists and is readable)
ls -l src/main/resources/reflect-config.json
quarkus.native.additional-build-args=-H:ResourceConfigurationFiles=src/main/resources/reflect-config.json
Defensive patterns

Strategy: try-catch

Validate before calling

Path json = Path.of("src/main/resources/reflect-config.json");
if (!Files.isRegularFile(json) || !Files.isReadable(json)) {
    throw new IllegalStateException("Native-image config JSON missing or unreadable: " + json);
}
if (!Files.isWritable(targetDir)) {
    throw new IllegalStateException("Thin jar directory not writable: " + targetDir);
}

Try / catch

try {
    Files.copy(jsonPath, thinJarDirectory.resolve(jsonPath.getFileName().toString()));
} catch (IOException e) {
    throw new IllegalStateException("Failed to copy native-image JSON config " + jsonPath + " to " + thinJarDirectory
        + ": check permissions, disk space, and that the source file exists", e);
}

Prevention

When it happens

Trigger: Building the native image source jar with additional native-image JSON config files while the filesystem fails: thinJarDirectory cannot be created or the source jsonPath is unreadable (permissions, missing file, disk full, path is a directory).

Common situations: Read-only target/ directory; stale build processes locking files on Windows; a configured native-image config JSON path pointing to a file that was removed; insufficient disk space.

Related errors


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

Appendix: source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/pkg/jar/NativeImageSourceJarBuilder.java:125

    /**
     * This is done in order to make application specific native image configuration files available to the native-image tool
     * without the user needing to know any specific paths.
     * The files that are copied don't end up in the native image unless the user specifies they are needed, all this method
     * does is copy them to a convenient location
     */
    private static void copyJsonConfigFiles(ApplicationArchivesBuildItem applicationArchivesBuildItem, Path thinJarDirectory)
            throws IOException {
        for (Path root : applicationArchivesBuildItem.getRootArchive().getRootDirectories()) {
            try (Stream<Path> stream = Files.find(root, 1, IsJsonFilePredicate.INSTANCE)) {
                stream.forEach(new Consumer<Path>() {
                    @Override
                    public void accept(Path jsonPath) {
                        try {
                            Files.createDirectories(thinJarDirectory);
                            Files.copy(jsonPath, thinJarDirectory.resolve(jsonPath.getFileName().toString()));
                        } catch (IOException e) {
                            throw new UncheckedIOException(
                                    "Unable to copy json config file from " + jsonPath + " to " + thinJarDirectory,
                                    e);
                        }
                    }
                });
            }
        }
    }

    private static class IsJsonFilePredicate implements BiPredicate<Path, BasicFileAttributes> {

        private static final BiPredicate<Path, BasicFileAttributes> INSTANCE = new IsJsonFilePredicate();

        @Override
        public boolean test(Path path, BasicFileAttributes basicFileAttributes) {
            return basicFileAttributes.isRegularFile() && path.toString().endsWith(".json");
        }
    }

View on GitHub (pinned to e1c734241f)