Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven install error after deleting .m2 folder

Tags:

java

maven

I was instructed to delete the .m2 folder as I had a problem with one of the project dependencies but now when I tried to Maven > Clean, then Maven > Install the application I get the following error.

I've tried re-running Maven > Clean, Maven Install several times (as sometime it works this way) but no use. I still get the same error message.

Can someone please advice me how to resolve this problem?

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Inventory 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ crm ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ crm ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 73 source files to E:\springsource\workspace\Inventory\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\spring-context-support\3.1.0.RELEASE\spring-context-support-3.1.0.RELEASE.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\aspectj\aspectjrt\1.6.9\aspectjrt-1.6.9.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\slf4j\slf4j-api\1.5.10\slf4j-api-1.5.10.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\javax\servlet\jstl\1.2\jstl-1.2.jar; invalid CEN header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\spring-tx\3.0.7.RELEASE\spring-tx-3.0.7.RELEASE.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\security\spring-security-config\3.1.3.RELEASE\spring-security-config-3.1.3.RELEASE.jar; invalid CEN header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\hibernate\hibernate-entitymanager\3.6.0.Final\hibernate-entitymanager-3.6.0.Final.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar; Unexpected end of ZLIB input stream
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\hibernate\hibernate-commons-annotations\3.2.0.Final\hibernate-commons-annotations-3.2.0.Final.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\javax\transaction\jta\1.1\jta-1.1.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\spring-orm\3.1.0.RELEASE\spring-orm-3.1.0.RELEASE.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\commons-dbcp\commons-dbcp\1.2.2\commons-dbcp-1.2.2.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-plugin-registry\2.0.6\maven-plugin-registry-2.0.6.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-error-diagnostics\2.0.6\maven-error-diagnostics-2.0.6.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\commons-cli\commons-cli\1.0\commons-cli-1.0.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-artifact\2.0.6\maven-artifact-2.0.6.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-model\2.0.6\maven-model-2.0.6.jar; invalid LOC header (bad signature)
[INFO] 18 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.074s
[INFO] Finished at: Wed Oct 16 13:36:32 EET 2013
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project crm: Compilation failure: Compilation failure:
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\spring-context-support\3.1.0.RELEASE\spring-context-support-3.1.0.RELEASE.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\aspectj\aspectjrt\1.6.9\aspectjrt-1.6.9.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\slf4j\slf4j-api\1.5.10\slf4j-api-1.5.10.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\javax\servlet\jstl\1.2\jstl-1.2.jar; invalid CEN header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\spring-tx\3.0.7.RELEASE\spring-tx-3.0.7.RELEASE.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\security\spring-security-config\3.1.3.RELEASE\spring-security-config-3.1.3.RELEASE.jar; invalid CEN header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\hibernate\hibernate-entitymanager\3.6.0.Final\hibernate-entitymanager-3.6.0.Final.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar; Unexpected end of ZLIB input stream
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\hibernate\hibernate-commons-annotations\3.2.0.Final\hibernate-commons-annotations-3.2.0.Final.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\javax\transaction\jta\1.1\jta-1.1.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\springframework\spring-orm\3.1.0.RELEASE\spring-orm-3.1.0.RELEASE.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\commons-dbcp\commons-dbcp\1.2.2\commons-dbcp-1.2.2.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-plugin-registry\2.0.6\maven-plugin-registry-2.0.6.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-error-diagnostics\2.0.6\maven-error-diagnostics-2.0.6.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\commons-cli\commons-cli\1.0\commons-cli-1.0.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-artifact\2.0.6\maven-artifact-2.0.6.jar; invalid LOC header (bad signature)
[ERROR] error: error reading C:\Documents and Settings\vmuser\.m2\repository\org\apache\maven\maven-model\2.0.6\maven-model-2.0.6.jar; invalid LOC header (bad signature)
like image 317
MChan Avatar asked Oct 16 '13 11:10

MChan


People also ask

What happens if I delete .m2 repository?

It's perfectly safe to delete the folder . m2/repository as maven will re-download all the needed dependencies when needed except for your local projects.

Can I delete the .m2 folder?

Local Maven Repository location Usually this folder is named . m2/repository . To clear/delete your local maven repository cache, simply delete the . m2/repository folder.

Where is .m2 file in Maven?

It is created by the maven when you run any maven command. By default, maven local repository is %USER_HOME%/. m2 directory. For example: C:\Users\SSS IT\.


3 Answers

The whole problem resided in that I was right clicking on project folder, selecting Maven > Clean, then Maven > Install. When I right clicked on pom.xml and selected Maven > Install everything worked just fine.

like image 176
MChan Avatar answered Oct 12 '22 03:10

MChan


Did you also move the location of the maven repository?

Some maven versions had some trouble with whitespaces in path names. So you may try to change the location in settings.xml - then a mvn clean install should re-download everything.

Maybe some of those artifacts are re-downloaded but corrupt? I would then just delete them again and retry. Maybe the jars are HTML files from a proxy?

You can also execute mvn dependency:go-offline - this will download also plugins and everything else required to build the project.

like image 36
wemu Avatar answered Oct 12 '22 02:10

wemu


just create .m2 folder and run clean install command.

like image 37
Dark Knight Avatar answered Oct 12 '22 01:10

Dark Knight