Skip to content
Latchkey

Maven corrupt cached JAR "zip END header not found" in CI

A JAR cached in the local repository is incomplete or corrupt, so the JVM cannot read it as a zip. This typically follows a truncated download that Maven cached anyway, and it persists across runs until the bad file is removed.

What this error means

A compile, plugin, or test step fails with "error in opening zip file" or "zip END header not found" pointing at a JAR under ~/.m2/repository.

mvn output
[ERROR] Failed to execute goal ... on project app:
Error loading class path resource: java.util.zip.ZipException: zip END header not found
  at /home/runner/.m2/repository/com/example/lib/2.3.1/lib-2.3.1.jar

Common causes

A truncated download was cached

A download cut short by a network drop was stored in .m2, leaving a partial JAR that is not a valid zip.

A stale cache restored a corrupt entry

A CI cache key restored a .m2 that already contained a damaged artifact, so every run reuses the bad file.

How to fix it

Purge the corrupt artifact and re-download

  1. Delete the bad artifact from the local repo (or purge it via the plugin).
  2. Re-run so Maven fetches a fresh, complete copy.
  3. Confirm the JAR opens (unzip -t) before caching it again.
Terminal
mvn -B dependency:purge-local-repository -DmanualInclude=com.example:lib
mvn -B verify

Validate checksums on download

Fail fast on a bad transfer instead of caching it by enforcing checksum validation.

Terminal
mvn -B -C verify

How to prevent it

  • Enable strict checksum checks (-C) so bad downloads fail, not cache.
  • Avoid caching .m2 entries that failed verification.
  • Re-download artifacts that ever produced a zip error.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →