๐Ÿ”ด The Error You're Seeing

Confirm this matches your console output. If it does, you're in the right place.

ERROR LOG[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project my-app: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile failed: Error creating classloader for executable: java.util.zip.ZipException: invalid LOC header (bad signature)

โšก Quick Fix Works 80% of the time

Delete the corrupted JAR from your local Maven repository (.m2) and rebuild.

# Delete entire repository (Nuclear option) rm -rf ~/.m2/repository # Rebuild mvn clean install

๐Ÿง  Why this Happens

Tap to expand the deep technical explanation

Maven tries to read a downloaded dependency JAR file (which is just a ZIP archive), but the file is corrupted or incomplete. The Java ZIP parser checks the file header, sees it doesn't match the expected format, and throws the exception.

The HITEC City Parking Spot Analogy:

Imagine buying a ziplock bag of rice at the grocery store. When you get home, you realize the bag has a hole in it and the rice is moldy (corrupted). You must throw it away and go back to the store to buy a fresh one.

๐Ÿ” How to Reproduce Confirm this is your error

Run mvn clean install after a previously interrupted download left a corrupted JAR in your local .m2 repository. Maven fails with ZipException: invalid LOC header (bad signature).

๐Ÿ› ๏ธ Solutions (3 Ways to Fix)

Solution 1โœ“ Most common cause

Clear the local Maven cache

๐Ÿ‘‰ Use this if a network interruption corrupted a downloaded dependency.

Maven downloads dependencies to a local folder (.m2/repository). If a file was partially downloaded or corrupted, Maven can't read it as a ZIP file. Deleting it forces Maven to download it again.

# Find the specific corrupt jar and delete it: rm -rf ~/.m2/repository/com/fasterxml/jackson/core/jackson-databind # Or clear everything (takes longer to rebuild): rm -rf ~/.m2/repository/* mvn clean install
Solution 2

Run Maven with -U flag

๐Ÿ‘‰ Use this if you think a snapshot dependency is corrupted.

The -U flag forces Maven to check for updated versions and re-download snapshots.

mvn clean install -U
Solution 3

Check corporate proxy/VPN

๐Ÿ‘‰ Use this if downloads keep failing or getting corrupted.

Corporate firewalls can truncate large file downloads or inject HTML error pages into JAR files.

# Check your settings.xml for proxy config ~/.m2/settings.xml

๐Ÿ“‹ Version Notes

Spring Boot 2.x

Maven build error.

Spring Boot 3.x

Maven build error.

๐Ÿ›ก๏ธ How to Prevent This Next Time

Ensure stable network connections when building projects for the first time. Use a corporate Nexus or Artifactory repository manager to cache dependencies reliably.

Course Search
Search across all chapters & stages
๐Ÿ“–

Search the course

Type any topic โ€” branching, stash, rebase, hooks โ€” and jump straight to that chapter.

merge branchesgit stashundo commitrebase