apache/flink · error · ProgramInvocationException

{e.getMessage()}

Error message

{e.getMessage()}

What it means

Thrown when JarUtils.checkJarFile(jarUrl) throws an IOException. This check validates that the jar is a well-formed, accessible jar file. The message is passed through verbatim from the underlying IOException (e.getMessage()), so it carries the specific validation failure reason.

Source

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

                            final String name = jarEntry.getName();
                            return name.length() > 8
                                    && name.startsWith("lib/")
                                    && name.endsWith(".jar");
                        })
                .collect(Collectors.toList());
    }

    private static void deleteExtractedLibraries(List<File> tempLibraries) {
        for (File f : tempLibraries) {
            f.delete();
        }
    }

    private static void checkJarFile(URL jarfile) throws ProgramInvocationException {
        try {
            JarUtils.checkJarFile(jarfile);
        } catch (IOException e) {
            throw new ProgramInvocationException(e.getMessage(), e);
        } catch (Throwable t) {
            throw new ProgramInvocationException(
                    "Cannot access jar file"
                            + (t.getMessage() == null ? "." : ": " + t.getMessage()),
                    t);
        }
    }

    @Override
    public void close() {
        try {
            userCodeClassLoader.close();
        } catch (IOException e) {
            LOG.debug("Error while closing user-code classloader.", e);
        }
        try {
            deleteExtractedLibraries();
        } catch (Exception e) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Read the chained IOException message for the specific validation failure.
  2. Validate the jar locally: 'jar tf your.jar' should list entries without error.
  3. Re-download or rebuild the jar if it is corrupt.
  4. Ensure the file is a JAR (zip with META-INF/MANIFEST.MF), not a raw zip or tar.
Defensive patterns

Strategy: validation

Validate before calling

try (JarFile test = new JarFile(jarFile)) {
    if (test.getManifest() == null) {
        throw new IllegalArgumentException("Jar has no manifest: " + jarFile);
    }
}

Try / catch

try {
    PackagedProgram.newBuilder().setJarFile(jarFile).build();
} catch (ProgramInvocationException e) {
    if (e.getMessage() != null && e.getMessage().contains("jar")) {
        // jar validation failure — check integrity
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling checkJarFile or building a PackagedProgram with a URL pointing to a file that is not a valid jar, is truncated, or has an unreadable manifest. The IOException from JarUtils carries details like 'Error opening jar file' or 'Invalid jar manifest'.

Common situations: Passing a plain zip (not jar), a jar that was corrupted in transit, or a URL to a remote resource that returned an HTML error page instead of a jar.

Related errors


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