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)
Andre
  • 453
  • 1
  • 4
  • 11
  • A Maven log would be useful... And Maven is supposed to retry when a download fails (at least when a checksum fails). – Tristan Aug 16 '11 at 05:58
  • 1
    First if you are running from command line update to the most recent version of maven (3.0.3) – khmarbaise Aug 16 '11 at 06:08
  • Have you tried using other repositories than the one above? – fgysin Aug 16 '11 at 06:10
  • Furthermore it sounds like networking problems.... – khmarbaise Aug 16 '11 at 06:17
  • I agree with the networking issue, but just couldn't track it down as it works fine from the same box inside a browser. – Andre Aug 16 '11 at 06:18
  • 1
    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 http://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! – Andre Aug 16 '11 at 06:22
  • Well looks like upgrading to Maven v3.0.3 breaks the download in another area. :-/ Will try and add output to original question. – Andre Aug 16 '11 at 20:46
  • Could you post your settings.xml as well? – Jon7 Aug 16 '11 at 21:29
  • Had the same problem once, it turned out it was the proxy server. Had to keep trying again and again and eventually it worked. – prunge Aug 17 '11 at 00:23

7 Answers7

18

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. (!!!!)

Lee Kamentsky
  • 631
  • 5
  • 6
17

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

David
  • 171
  • 1
  • 2
  • 2
    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_). – Lucas Jul 06 '12 at 20:09
  • 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. :( – John K Aug 31 '12 at 22:33
  • Give this guy a medal! – xmlParser Jan 22 '19 at 08:32
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.

Andre
  • 453
  • 1
  • 4
  • 11
  • 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. – Rich Oct 13 '11 at 10:40
  • @Rich Here's the details on adding a mirror [http://maven.apache.org/guides/mini/guide-mirror-settings.html] and the mirror itself was the ibiblio mirror with specs here [http://repo1.maven.org/maven2/.meta/repository-metadata.xml] – Andre Oct 13 '11 at 16:16
  • 4
    Thanks. Neither mirror worked for me, but I fixed the problem by downgrading from Java 7 to Java 6 – Rich Oct 14 '11 at 13:25
4

I solved this problem by downgrading to Java 6.

Adam Lear
  • 38,111
  • 12
  • 81
  • 101
DigCamara
  • 5,540
  • 4
  • 36
  • 47
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.

X. Wo Satuk
  • 923
  • 1
  • 11
  • 18
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?

cschooley
  • 586
  • 4
  • 10
  • 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)? – Andre Aug 16 '11 at 21:38
  • 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). – cschooley Aug 16 '11 at 21:49
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
Ondrej Burkert
  • 6,617
  • 2
  • 32
  • 27