๐ด The Error You're Seeing
Confirm this matches your console output. If it does, you're in the right place.
[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)
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 installRun 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 -UCheck 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
Maven build error.
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.