Maven failing to download jar dependencies
Asked Answered
P

7

39

I have a very simple default application that I've created to test my Eclipse Indigo/Maven v3.0.1 setup on my Windows 7 machine. The Hello World app runs fine from Eclipse.

Now from the command line I'm trying to test with mvn install.

At which point I see Maven download a large series of dependencies. For some reason though it will get stuck downloading one and will just stop part way through. It's not at the same point each time, but it's currently consistently the same jar file, eg...

http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-booter/2.5/surefire-booter-2.5.jar

If I download this file from a browser it works perfectly. Quite fast in fact. Now if I manually copy that downloaded file to the appropriate directory in my .m2 repository directory, the install continues to download dependencies until it hits another one at random which it stops at.

Here's my POM, although I'm not sure it'll help as it's so basic and seems to work fine with a mvn compile.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.kyeema</groupId>
  <artifactId>QServer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>QServer</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Here's some debug output referencing some dummy jar file?

[INFO] Surefire report directory: C:\workspace\QServer\target\surefire-reports
[DEBUG] Setting system property [user.dir]=[C:\workspace\QServer]
[DEBUG] Setting system property [localRepository]=[C:\Users\Andre\.m2\repository]
[DEBUG] Setting system property [basedir]=[C:\workspace\QServer]
[DEBUG] Using JVM: C:\Program Files\Java\jdk1.7.0\jre\bin\java
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG]   org.apache.maven.surefire:surefire-booter:jar:2.7.2:compile (selected for compile)
[DEBUG]     org.apache.maven.surefire:surefire-api:jar:2.7.2:compile (selected for compile)
[DEBUG] Adding to surefire booter test classpath: C:\Users\Andre\.m2\repository\org\apache\maven\surefire\surefire-booter\2.7.2\surefire-booter-2.7.2.jar Scope: compile
[DEBUG] Adding to surefire booter test classpath: C:\Users\Andre\.m2\repository\org\apache\maven\surefire\surefire-api\2.7.2\surefire-api-2.7.2.jar Scope: compile
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[WARNING] Missing POM for org.apache.maven.surefire:surefire-junit3:jar:2.7.2: Error resolving project artifact: Failure to find org.apache.maven.surefire:surefire-junit3:pom:2.7.2 in http://mirrors.ibiblio.org/pub/mirrors/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of ibiblio.org has elapsed or updates are forced for project org.apache.maven.surefire:surefire-junit3:pom:2.7.2
[DEBUG]   org.apache.maven.surefire:surefire-junit3:jar:2.7.2:test (selected for test)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.626s
[INFO] Finished at: Tue Aug 16 13:18:42 PDT 2011
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project QServer: Error to resolving surefire provider dependency: Missing:
[ERROR] ----------
[ERROR] 1) org.apache.maven.surefire:surefire-junit3:jar:2.7.2
[ERROR] 
[ERROR] Try downloading the file manually from the project website.
[ERROR] 
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.7.2 -Dpackaging=jar -Dfile=/path/to/file
[ERROR] 
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.7.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR] 
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
[ERROR] 2) org.apache.maven.surefire:surefire-junit3:jar:2.7.2
[ERROR] 
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR] 
[ERROR] for artifact:
[ERROR] dummy:dummy:jar:1.0
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR] ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2, releases=true, snapshots=false)
Patinated answered 16/8, 2011 at 5:43 Comment(9)
A Maven log would be useful... And Maven is supposed to retry when a download fails (at least when a checksum fails).Ingrowing
First if you are running from command line update to the most recent version of maven (3.0.3)Tass
Have you tried using other repositories than the one above?Basilio
Furthermore it sounds like networking problems....Tass
I agree with the networking issue, but just couldn't track it down as it works fine from the same box inside a browser.Patinated
Oops. Hit enter too soon. I'm not sure it's a checksum error, but would have put a log in if I didn't find the workaround. I found "a" solution. I added a mirror to my settings.xml file to point to mirrors.ibiblio.org/pub/mirrors/maven2 and it worked first time. I'm now also going to upgrade to 3.0.3 and see if that fixes it. Thanks everyone!Patinated
Well looks like upgrading to Maven v3.0.3 breaks the download in another area. :-/ Will try and add output to original question.Patinated
Could you post your settings.xml as well?Dale
Had the same problem once, it turned out it was the proxy server. Had to keep trying again and again and eventually it worked.Mariano
P
5

Well for what it's worth, here's the answer to what I've been experiencing.

If I leave Maven at v3.0.1 I have to add the mirror listed above and it works fine.

If I upgrade Maven to v3.0.3 then I have to remove the mirror listed above to make it work. :-)

I tried this on two separate machines and had identical behaviour. This could mean the network here is to blame as they both go through the same router.

Anyway, so there's essentially two workarounds there. I'm not sure if either are the "correct" response, but they keep me moving forward at least.

Thanks to all that submitted answers.

Patinated answered 16/8, 2011 at 22:57 Comment(3)
I have the same problem, but I can't fix it. What do you mean by "the mirror listed above". This happens for me with maven 2.2.1, 2.2.0 and 3.0.3.Zirconia
@Zirconia Here's the details on adding a mirror [maven.apache.org/guides/mini/guide-mirror-settings.html] and the mirror itself was the ibiblio mirror with specs here [repo1.maven.org/maven2/.meta/repository-metadata.xml]Patinated
Thanks. Neither mirror worked for me, but I fixed the problem by downgrading from Java 7 to Java 6Zirconia
N
19

OK guys, I had the same problem downloading a large file. We're all probably using the lightweight HTTP wagon. If you look at the docs:

http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/

Known Limitation:

The main limitation is that you can't download data that doesn't fit entirely into memory.

So I increased the memory for Maven:

export MAVEN_OPTS="-Xmx1024m"

and voila, it works. (!!!!)

Narwhal answered 25/6, 2013 at 19:14 Comment(2)
Since your comment was posted in 2013, I wanted to point out that this still worked for me today (2018) with Maven version 3.0.5 and Java version 1.8.0_162. Thanks!Balladry
Still helps in 2020Duumvir
V
17

I had the same problem. In my case AVG antivirus software blocked Maven from downloading artifacts. Disabling it temporarily helped.

Virescence answered 18/4, 2012 at 7:41 Comment(3)
More specifically, AVG Link Scanner in combination with Java 7. Disable that AVG Link Scanner or revert back to Java 6 and you should be good to go (I tried it 3 or 4 times turning each component on and off, I'm pretty certain it is just the link scanner).Lauter
I tried to add an exception to the AVG Online Shield for the location of the JARs to no avail. Had to temporarily disable AVG in order to download artifacts. :(Tephra
Give this guy a medal!Sienese
P
5

Well for what it's worth, here's the answer to what I've been experiencing.

If I leave Maven at v3.0.1 I have to add the mirror listed above and it works fine.

If I upgrade Maven to v3.0.3 then I have to remove the mirror listed above to make it work. :-)

I tried this on two separate machines and had identical behaviour. This could mean the network here is to blame as they both go through the same router.

Anyway, so there's essentially two workarounds there. I'm not sure if either are the "correct" response, but they keep me moving forward at least.

Thanks to all that submitted answers.

Patinated answered 16/8, 2011 at 22:57 Comment(3)
I have the same problem, but I can't fix it. What do you mean by "the mirror listed above". This happens for me with maven 2.2.1, 2.2.0 and 3.0.3.Zirconia
@Zirconia Here's the details on adding a mirror [maven.apache.org/guides/mini/guide-mirror-settings.html] and the mirror itself was the ibiblio mirror with specs here [repo1.maven.org/maven2/.meta/repository-metadata.xml]Patinated
Thanks. Neither mirror worked for me, but I fixed the problem by downgrading from Java 7 to Java 6Zirconia
S
4

I solved this problem by downgrading to Java 6.

Scrouge answered 12/1, 2012 at 2:7 Comment(0)
M
3

In my case, I went to the local repository (~/.m2/repository/), found the corresponding group and discovered that the artifact at which the download is stuck has two files with .part and .part.lock extensions. Deleting them helped.

Multiangular answered 6/8, 2019 at 16:26 Comment(0)
T
2

I had exactly the same problem a while back - long story short it was a networking issue. And, yes just like you tried I could grab the file with a web browser just fine.

For testing purposes are you using a proxy, and to the proxy settings in Maven match the browser?

Tutuila answered 16/8, 2011 at 21:35 Comment(2)
I haven't entered any proxy settings at all, but I'm wondering if it's some black magic from my router when connecting to my ISP (Comcast)?Patinated
So home ISP not a corporate network - ISPs like to dink around with HTTP. In my case the proxy was the prefered method to use http, but we could skip it with the understanding that some traffic could get dropped by QoS - that's what was happening to me. I'm going to poke around to see if I find a way to set maven retries or http options - maybe the browser is retrying for you or just doing something different than mvn (like HTTP PUSH - or not).Tutuila
T
0

I had similar issue. What changed was the move of nexus to VPN. Turned out I had DNS entry cached.

Flushing DNS fixed it. For record for Ubuntu like systems:

sudo systemd-resolve --flush-caches
Tichon answered 31/1, 2018 at 15:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.