tags:

views:

657

answers:

3

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?

+1  A: 

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/

DataSurfer
I dont think its any of these - I tried removing the settings.xml and building a new project. The output is in my edits to the qn.
Andrew Bucknell
I did notice that it switched from repository.exoplatform.org to repo1.maven.org. I wonder if your Java install is trying to use a borked proxy somehow. You might want to write a small Java app that does a URL.openStream on different URLs and see what happens. Make sure it is using the same JVM as maven.
DataSurfer
+1  A: 

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

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.

JoseK
Thanks for the mvn -X suggestion. I am getting case 1 Caused by: java.net.UnknownHostException: repo1.maven.org at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)The machine is definitely connected to the network. I can browse the repository via lynx, and am able to resolve the hostname to an ip using nslookup.
Andrew Bucknell
Does any other mvn target work? Others on the maven forums have issues with archetype-plugin, but you've not downloaded it yet so this might not be it - https://issues.sonatype.org/browse/MNGECLIPSE-948?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aworklog-tabpanelI was almost going to suggest you upgrade to jdk 1.6.0_20 until I saw your name on the forum.
JoseK
+1  A: 

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.

Andrew Bucknell