quarkusio/quarkus · error · IOException

Unexpected end of stream while reading application config fi

Error message

Unexpected end of stream while reading application config file: ${resourceName}

What it means

An IOException thrown by the AOT deserializer's readBytes helper when the serialized application stream ends before the declared number of bytes for an application config entry could be read. It means the serialized application image (.dat file) is truncated or written by an incompatible writer.

Source

Thrown at independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/AotSerializedApplication.java:363

        } else {
            List<ApplicationConfigEntry> entries = new ArrayList<>(jarEntryCount);
            for (int j = 0; j < jarEntryCount; j++) {
                String url = data.readUTF();
                int dataLength = data.readInt();
                byte[] content = readBytes(data, dataLength, configFileName);
                entries.add(new ApplicationConfigEntry(url, content));
            }
            return entries;
        }
    }

    private static byte[] readBytes(DataInputStream data, int length, String resourceName) throws IOException {
        byte[] content = new byte[length];
        int totalRead = 0;
        while (totalRead < length) {
            int read = data.read(content, totalRead, length - totalRead);
            if (read == -1) {
                throw new IOException(
                        "Unexpected end of stream while reading application config file: " + resourceName);
            }
            totalRead += read;
        }
        return content;
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Regenerate the serialized application image by re-running the package/AOT build (mvn clean package).
  2. Verify the image file size matches the artifact produced by the build (re-deploy if copied).
  3. Ensure the Quarkus runtime version matches the version that produced the image (check VERSION compatibility).
  4. Check build logs for earlier failures (e.g. disk-full) that aborted serialization.

Example fix

// before
cp app.dat /deploy/app.dat  # partially copied
// after
mvn clean package && sha256sum target/*.dat && cp target/*.dat /deploy/app.dat && sha256sum /deploy/app.dat
Defensive patterns

Strategy: validation

Validate before calling

Path img = Path.of("app.dat");
if (!Files.isRegularFile(img) || Files.size(img) == 0) throw new IllegalStateException("serialized app image missing or empty: " + img);
// compare against expected checksum from build if available

Type guard

boolean looksLikeSerializedApp(Path p) throws IOException { try (var in = new DataInputStream(Files.newInputStream(p))) { return in.available() >= 4; } }

Try / catch

try { app.start(); } catch (IOException e) { if (e.getMessage().startsWith("Unexpected end of stream")) { log.error("Truncated serialized image: regenerate it", e); throw new IllegalStateException("Re-run package build", e); } throw e; }

Prevention

When it happens

Trigger: readBytes, called while deserializing application config entries (content/content1/content2), hits EOF (read == -1) before reading `length` bytes — a short/aborted write or corrupted serialized image.

Common situations: The serialized app file was truncated by disk-full or killed build process; the image was produced by a different Quarkus version with a changed format; manual copy/partial upload of the image artifact.

Related errors


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