views:

543

answers:

2

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.

A: 

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.

bmargulies
How can I do that? I am new to Maven. I didn't configure that repository. I am only using the default one.
savanna
Also, Maven actually installs the corrupted jars. I would hope Maven simple discard the files. That would be so much better.
savanna
java.net is not a default repository. Someone put it into your repository list.The maven user list is a better place to ask if there's a way to make it reject the redirect.
bmargulies
+3  A: 

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
cetnar
I am using 2.2.1. But I am also using m2eclipse in Eclipse. It is going to be difficult to have all our development team to do the additional params. I hope Maven will fix this problem soon. Currently my work around is installing a local repository server, in the server I set strict checksum policy to all repositories.
savanna
This is not "kind of" it _is_ bug.Thanks for your advice it helped me.
Petr Gladkikh