Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven downloads corrupted Jars

I am running into a maven problem that's killing all my hairs.

So at the beginning all my maven project works fine. And then when I switched to a new computer today and trying to compile them all.

The first error I see from Eclipse is IO error reading jar files from the local maven repository. Then I googled and someone suggested this is some corrupted files, simply delete them and let maven rebuild the repository.

That solves the problem for a while. And then it keeps popping up again and again.

I got tired and removed the whole local repository and did everything all over again. Then I found out the cause:

The maven remote repository is BAD.

So here is part of the console messages.

[INFO] Unable to find resource 'org.apache.ws.commons.axiom:axiom-dom:jar:1.2.8'
 in repository eclipse-repo (http://repo1.maven.org/eclipse)
Downloading: https://maven-repository.dev.java.net/nonav/repository//org.apache.
ws.commons.axiom/jars/axiom-dom-1.2.8.jar
373b downloaded  (axiom-dom-1.2.8.jar)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '2c6102c2c3
70e0b993e897e981618ed448651147'; remote = ' 

The file contains an http redirect.

301 Moved Permanently

Moved Permanently

The document has moved here.


Apache Server at maven-repository.dev.java.net Port 443

I am stuck. How can I get the real dependency jars? How can I tell maven to avoid this? This is really annoying.

like image 662
savanna Avatar asked Dec 11 '09 00:12

savanna


1 Answers

There is king of bug in maven, simply because maven does not skip taking an artifact if one of the maven repo sends a 301(MOVED PERMANANTLY) and it simply take that message and write it as the pom file. Simply if the maven repo sends 404 it skip that repo and go for another, but here with 301 it just dump the message as the pom file and later on this failes.

I assuming you're using Maven 2.2.1? If yes try, to downgrade to Maven 2.2.0 or use additional setting. In 2.2.1 was change in wagon implementation.

Maven 2.2.1 aims to correct several critical regressions related to the selection of the HttpClient-based Wagon implementation for HTTP/HTTPS transfers in Maven 2.2.0. The new release reverts this selection, reinstating the Sun-based - or lightweight - Wagon implementation as the default for this sort of traffic.

However, Maven 2.2.1 goes a step further to provide a means of selecting which provider - or implementation - the user wishes to use for a particular transfer protocol.

So, try run maven with additional params.

mvn -Dmaven.wagon.provider.http=httpclient clean install
like image 84
cetnar Avatar answered Oct 13 '22 22:10

cetnar