Andrew Bucknell
Andrew Bucknell

Reputation: 1950

What could be causing 'error transferring file' in maven?

I have installed maven 2.2.1 on my debian machine and getting the following error

[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retrieved  from repository: central due to an error: Error transferring file: repository.exoplatform.org

What I have been able to find relating to this problem is its typically caused by not having proxy settings correctly configured or a firewall blocking traffic, but I dont have either on this machine. Also, I have the same settings file on my windows machine and it works fine.

Any suggestions would be greatly appreciated as I am stumped.

exo@melb-web:~/test$ mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-07 05:16:01+1000)
Java version: 1.5.0_22
Java home: /usr/local/bin/jdk1.5.0_22/jre
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux" version: "2.6.22-3-amd64" arch: "i386" Family: "unix"
exo@melb-web:~/test$ mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retrieved from repository: central due to an error: Error transferring file: repository.exoplatform.org
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jun 30 10:18:33 EST 2010
[INFO] Final Memory: 2M/136M
[INFO] ------------------------------------------------------------------------

* EDIT *

I tried removing the settings.xml and generating a new maven project. I got the following

exo@melb-web:~/test$ mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retrieved from repository: central due to an error: Error transferring file: repo1.maven.org
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jun 30 11:40:26 EST 2010
[INFO] Final Memory: 1M/136M
[INFO] ------------------------------------------------------------------------

I think this rules out it being a problem with the settings.xml or a pom. Is there a way to get more information about why maven cant connect to the repository?

Upvotes: 11

Views: 69943

Answers (7)

Anderson
Anderson

Reputation: 2752

Don't forget to turn off your VPN especially for Chinese people. It's an SSL handshake issue.

Upvotes: 0

venkatram mutyala
venkatram mutyala

Reputation: 1

The quick "solution" is to give fully qualified plugin name in the command :

mvn org.mortbay.jetty:maven-jetty-plugin:run

Upvotes: 0

JoseK
JoseK

Reputation: 31371

I've tried the same commands and get the same error message, so I've run using the debug flag. This gives a different root exception depending on the proxy settings etc. Try running the same in case you get better verbose output.

mvn -X archetype:generate

Case 1:

Machine not connected to network (Cable disabled) gives a debug message

[DEBUG] Exception
org.apache.maven.wagon.TransferFailedException: Error transferring file
...
Caused by: java.net.UnknownHostException: repo1.maven.org
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
[INFO] Repository 'central' will be blacklisted

Case 2:

Machine connected with incorrect proxy gives the debug message

[DEBUG] Exception
org.apache.maven.wagon.TransferFailedException: Error transferring file
...
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
[INFO] Repository 'central' will be blacklisted

Here error could be 403, connection reset or Authorization or access forbidden error

Case 3:

Machine with direct connection to internet

[DEBUG] Trying repository central
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archet
ype-plugin/2.0-alpha-5/maven-archetype-plugin-2.0-alpha-5.jar
[DEBUG]   Artifact resolved
[INFO] ------------------------------------------------------------------------

and so on till it works.

Upvotes: 10

Tires
Tires

Reputation: 1602

Update to maven 3.0.4 or up, if possible.

I've studied the maven source code: There is a bootstrap problem inside maven 2.2.1. The proxy is looked up as HTTPS when accessing HTTPS servers, but you only can have one proxy as active. There is no fallback to HTTP proxy. In maven 3.0.4 this issue seems to be solved.

Upvotes: 0

marc meyer
marc meyer

Reputation: 580

I had the same problem. In my case it was actually a leftover settings.xml file from a prior job. I backed up and removed ~/.m2/settings.xml and the build went through just fine.

Upvotes: 0

Andrew Bucknell
Andrew Bucknell

Reputation: 1950

Just to close the loop on this one - it turned out to be an issue with the libraries debian had available for java uses to resolve hostnames. The fix is to apply a new libdns for java as described here http://www.ehow.com/how_4747553_fix-unknownhostexception-java-applications-ubuntu.html. Once I did this I am able to run mvn with jdk5 and jdk6.

Upvotes: 3

Gabriel
Gabriel

Reputation: 1751

I would guess it has something to do with the repository settings in the pom, a parent pom or in your ~/.m2/settings.xml file. Its also possible that the repo at exoplatform is misconfigured.

With no repositories set the archetype plugin would come from repo1.maven.org

http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/

Upvotes: 2

Related Questions