71

I configured Maven 3.0.3 and tried to download a sample project using archetypes with this command:

mvn archetype:generate -DarchetypeGroupId=org.graniteds.archetypes 
                       -DarchetypeArtifactId=graniteds-tide-spring-jpa-hibernate 
                       -DgroupId=org.example 
                       -DartifactId=gdsspringflex 
                       -Dversion=1.0-SNAPSHOT

(Command from this link : http://java.dzone.com/articles/enterprise-ria-spring-3-flex-4 )

And I got this error:

Downloading: repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.4.1: Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1

Downloading: repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.3.1/maven-install-plugin-2.3.1.pom

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.3.1: Plugin org.apache.maven.plugins:maven-install-plugin:2.3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.3.1
.
.
.
Downloading: repo1.maven.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: repo1.maven.org/maven2/org/codehaus/mojo/maven-metadata.xml

[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (repo1.maven.org/maven2): Error transferring file: Connection refused: connect

[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (repo1.maven.org/maven2): Error transferring file: Connection refused: connect
Downloading: repo1.maven.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: repo1.maven.org/maven2/org/codehaus/mojo/maven-metadata.xml

[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (repo1.maven.org/maven2): Error transferring file: Connection refused: connect

[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (repo1.maven.org/maven2): Error transferring file: Connection refused: connect
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.479s
[INFO] Finished at: Tue Oct 18 12:44:58 BST 2011
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------

[ERROR] No plugin found for prefix 'archetype' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\krsl1254\.m2\repository), central (repo1.maven.org/maven2)] -> [Help 1]

I tried searching some posts similar to this but couldn't get an answer. I tried changing proxy settings in settings.xml but it still doesn't work. Could you please help me out?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Basith
  • 831
  • 1
  • 7
  • 14
  • 3
    your maven client can't access repo1.maven.org. I think there's still something wrong with your settings.xml. Post it. – HefferWolf Oct 19 '11 at 09:32
  • @HefferWolf...here is the current settings: – Basith Oct 19 '11 at 09:59
  • 2
    ehm, that proxy setting is completly commented? You need to uncomment the proxy block and enter exactly the same proxy data you use in your browser. – HefferWolf Oct 19 '11 at 10:16
  • @HefferWolf: aaah..sorry about that comment..had it uncommented when i was trying out some settings, then commented it back..hmmm proxy settings in my browser..because i ve a normal account (not an administrator one), i m not able to see the proxy settings in my browser..have to check how to get those settings..Thanks for that HefferWolf...much appreciated.. – Basith Oct 19 '11 at 10:37
  • 1
    If you don't know your proxy settings go to http://superuser.com/a/346376 – omerhakanbilici Jan 14 '15 at 15:42

17 Answers17

81

I had the same error. In my case I am using Netbeans 7.1.2, I am posting this because maybe someone end up here same as I did.

I tried to configure the proxy options from the GUI, but the documentation says that maven doesn't read those. So I checked the NetBeans FAQ here :

What mainly you have to do is create (if it does not exist) a settings.xml under

user.home/.m2/settings.xml

if you don't have it you can copy from

netbeans.home/java/maven/conf/settings.xml

then uncomment if you already have it otherwise just fill this section:

<proxies>
 <proxy>
   <active>true</active>
   <host>myproxy.host.net</host>
   <port>80</port>
 </proxy>
</proxies>

you have to check your proxy configuration and replace it there

Snake Sanders
  • 2,641
  • 2
  • 31
  • 42
33

I had a similar issue with Eclipse and the same steps as Sanders did solve it. It happens because the proxy restricts call to maven repository

  1. Go to D:\Maven\apache-maven-3.0.4-bin\apache-maven-3.0.4\conf (ie your maven installation folder)
  2. Copy settings.xml and paste it in .m2 folder, which is in the users folder of your windows machine.
  3. Add the proxy setting

Something like this:

 <proxies>
    <!-- proxy
      Specification for one proxy, to be used in connecting to the network.
     -->
    <proxy>      
      <active>true</active>
      <protocol>http</protocol>
      <username>your username</username>
      <password>password</password>    
      <host>proxy.host.net</host>
      <port>80</port>  
    </proxy>

  </proxies>
ben75
  • 29,217
  • 10
  • 88
  • 134
  • 4
    Just to make a note. No need to transfer `settings.xml` from `conf` directory to `.m2` folder,in case your maven path is set correctly. Reason is `mvn` loads first its global settings first from `conf/settting.xml` then load local settings from .m2 folder. This can be read from log ` [DEBUG] Reading global settings from C:\apache-maven-3.1.1-bin\conf\settings.xml [DEBUG] Reading user settings from C:\.m2\settings.xml` – fiberair Mar 12 '15 at 15:59
6

I have to put

 <proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>http</protocol>
  <host>Your proxy host</host>
  <port>proxy host ip</port>
  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>

Before

 <proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>https</protocol>
  <host>Your proxy host</host>
  <port>proxy host ip</port>
  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>

Weird, but yes!, <protocol>http</protocol> has to come before <protocol>https</protocol>. It solved my problem. Hope it helps someone who faces connections issue even after enabling proxy settings in conf/settings.xml.

Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66
fiberair
  • 641
  • 7
  • 17
3

I wouldn't advise you to do this but on my personal computer I disabled the firewall so that maven could get the required plugins.

mar915h
  • 33
  • 3
  • as commented in one of the answeres above - for me it was company vpn that was setup in a way that block untrusted connection, when I switched it off, it downloaded the packages for me without a problem :) cheers! – roslyn Apr 15 '20 at 14:22
3

In my case, it was not worknig even after passing the proxy credentails.

Mistake was - forgot to remove the comment line.

<!-- proxy
 | Specification for one proxy, to be used in connecting to the network.

<proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>http</protocol>
  <username>345325</username>
  <password>dfgasdfg</password>
  <host>proxy.abc.com</host>
  <port>8080</port>
  <nonProxyHosts>proxy.abc.com</nonProxyHosts>
</proxy>
|-->    ----------REMOVE THIS LINE AND CLOSE It above <proxy> tag
Adriaan Koster
  • 15,870
  • 5
  • 45
  • 60
1

I was having exactly the same problem.I went to my IE setting->LAN Settings.Then copied the Address as host and port as the port and it worked. Following is the snapshot of the proxies tag in the Settings.xml that I changed.

<proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>http</protocol>
  <!--username>proxyuser</username>
  <password>proxypass</password-->
  <host>webtitan</host>
  <port>8881</port>
  <!--nonProxyHosts>local.net|some.host.com</nonProxyHosts-->
</proxy>

tester
  • 11
  • 1
1

I had to change my password to the latest in the user.home/.m2/settings.xml file!

Surekha
  • 582
  • 1
  • 7
  • 12
1

Thank it worked...

edit setting.xml

and replace proxy with this

Its working 100%

<proxy>      
  <active>true</active>
  <protocol>http</protocol>
  <username>your username</username>
  <password>password</password>    
  <host>proxy.host.net</host>
  <port>80</port>  

0

This problem will solve when we change the version of apache-maven

I faced it and it was solved when i used apache-maven-2.2.1

0

I had the same problem because I was using port 80 instead of 8080 in the settings.xml proxy configuration

Laura Liparulo
  • 2,849
  • 26
  • 27
0

Mac OSX 10.7.5: I tried setting my proxy in the settings.xml file (as mentioned by posters above) in the /conf directory and also in the ~/.m2 directory, but still I got this error. I downloaded the latest version of Maven (3.1.1), and set my PATH variable to reflect the latest install, and it worked for me right off the shelf without any error.

Hal
  • 69
  • 7
0

I had the same issue in Windows

and it worked since my proxy configuration in settings.xml file was changed

So locate and edit the file inside the \conf folder, for example : C:\Program Files\apache-maven-3.2.5\conf

<proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>jorgesys</username>
      <password>supercalifragilisticoespialidoso</password>
      <host>proxyjorgesys</host>
      <port>8080</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>
  • In my case i had to chage from port 80 to 8080
  • If you can´t edit this file that is located inside /program files you can make a copy, edit the file and replace the file located into /program files folder.
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
0

In my case, even my system is not behind proxy, I got same issue. I was able to resolve by typing mvn help:archetype before mvn archetype:generate

  • I think this helped? But make sure to switch back to archetype:generate or you'll keep getting the error. – Noumenon Jan 16 '17 at 20:03
0

If you created new settings.xml file instead of copy it from somewhere else, remember to put the tag inside :

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> <proxies> ..... </proxies> </settings>

ti.voodoo
  • 70
  • 8
0

For me, the solution given on the page maven is not able to download anything from central because ssl don't work worked, when running Mint 19 in a VM:

sudo apt install ca-certificates-java
sudo update-ca-certificates -f
Reinier Torenbeek
  • 16,669
  • 7
  • 46
  • 69
0

I got the error

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-compiler-plugin:3.6.0: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.6.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.6.0

Then I have solved by giving the proxy settings at ~/.m2/conf/settings.xml and <maven_install_loc>/conf/setting.xml as below .

<proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     | -->
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>jorgesys</username>
      <password>supercalifragilisticoespialidoso</password>
      <host>proxyjorgesys</host>
      <port>8080</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
   
  </proxies>
General Grievance
  • 4,555
  • 31
  • 31
  • 45
0

I had a similar issue with maven not downloading what it needs. I added this in my pom file and worked.

 <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
Clover
  • 11
  • 6