savanna
savanna

Reputation: 749

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.

Upvotes: 11

Views: 11307

Answers (3)

Thomas Bratt
Thomas Bratt

Reputation: 51912

I've seen this error with IntelliJ IDEA 13.1.5 and Ubuntu 14.04.

Maven 2.2.? saves the 301 response body as a jar file in the ~/.m2 cache, which causes problems later on during the build.

The fix for me was to install Maven 3. Instructions for Ubuntu 14.04 are here:

http://www.sysads.co.uk/2014/05/install-apache-maven-3-2-1-ubuntu-14-04/

Upvotes: 0

cetnar
cetnar

Reputation: 9415

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

Upvotes: 21

bmargulies
bmargulies

Reputation: 100123

One answer: avoid dev.java.net. It's often broken in one way or the other. If you need things from there, install them in a local repository manager.

Upvotes: 0

Related Questions