apache/flink · error · ProgramInvocationException

An I/O error occurred while extracting nested library '{inpu

Error message

An I/O error occurred while extracting nested library '{input.getName()}' to temporary file '{output.getAbsolutePath()}'.

What it means

Thrown when an IOException occurs while copying a nested jar entry to a temporary file during library extraction. The stream copy loop (read from JarEntry input, write to temp File output) failed. Both the source entry name and the target temp file path are included in the message for diagnosis.

Source

Thrown at flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java:575

        } catch (Throwable t) {
            throw new ProgramInvocationException(
                    "Unknown I/O error while extracting contained jar files.", t);
        }
    }

    private static File copyLibToTempFile(
            String name, Random rnd, JarFile jar, JarEntry input, byte[] buffer)
            throws ProgramInvocationException {
        final File output = createTempFile(rnd, input, name);
        try (final OutputStream out = new FileOutputStream(output);
                final InputStream in = new BufferedInputStream(jar.getInputStream(input))) {
            int numRead = 0;
            while ((numRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, numRead);
            }
            return output;
        } catch (IOException e) {
            throw new ProgramInvocationException(
                    "An I/O error occurred while extracting nested library '"
                            + input.getName()
                            + "' to temporary file '"
                            + output.getAbsolutePath()
                            + "'.");
        }
    }

    private static File createTempFile(Random rnd, JarEntry entry, String name)
            throws ProgramInvocationException {
        try {
            final File tempFile = File.createTempFile(rnd.nextInt(Integer.MAX_VALUE) + "_", name);
            tempFile.deleteOnExit();
            return tempFile;
        } catch (IOException e) {
            throw new ProgramInvocationException(
                    "An I/O error occurred while creating temporary file to extract nested library '"
                            + entry.getName()

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Free up space in the temp directory or point java.io.tmpdir to a larger volume.
  2. Check disk quota with 'df -h' and 'du -sh /tmp'.
  3. Re-examine the jar for corrupt nested jars (run 'jar tf' and look for unusual entries).
  4. If in Kubernetes, increase the emptyDir or ephemeral-storage size.

Example fix

// before: default tmp dir too small
java ... -Djava.io.tmpdir=/small/tmp

// after: point to a volume with sufficient space
java ... -Djava.io.tmpdir=/data/flink-tmp
Defensive patterns

Strategy: validation

Validate before calling

File tmpDir = new File(System.getProperty("java.io.tmpdir"));
long freeSpace = tmpDir.getUsableSpace();
if (freeSpace < requiredBytes) {
    throw new IllegalStateException("Insufficient temp space: " + freeSpace);
}

Try / catch

try {
    PackagedProgram.extractContainedLibraries(jarUrl);
} catch (ProgramInvocationException e) {
    if (e.getMessage().contains("I/O error occurred while extracting nested library")) {
        // check disk space and permissions
    }
    throw e;
}

Prevention

When it happens

Trigger: Disk full during extraction, temp file permissions revoked mid-copy, the nested jar entry is corrupt and the read fails, or the output stream is closed externally. Triggered inside copyLibToTempFile.

Common situations: Container /tmp volume is too small for the extracted libraries, disk quota exceeded, or the jar contains a malformed nested jar entry that causes a read error.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/91d31587ea67eaac. Report an issue: GitHub.