Maven proxy settings not working

Go To StackoverFlow.com

10

I have setup maven proxy settings in conf/settings.xml as

<proxy>
  <active>true</active>
  <protocol>http</protocol>
  <host>proxy.my-company.com</host>
  <port>8080</port>
</proxy>

but when I run maven build, I am getting following error. Can someone please help

[WARNING] The POM for org.apache.maven.wagon:wagon-ssh:jar:2.2 is missing, no dependency information available

detailed log

mvn -X

Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
Maven home: C:\tools\apache-maven-3.0.4
Java version: 1.6.0_12, vendor: Sun Microsystems Inc.
Java home: C:\tools\Java\jdk1.6.0_12\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"

[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from C:\tools\apache-maven-3.0.4\conf\settings.xml
[DEBUG] Reading user settings from C:\Documents and Settings\desibaba\.m2\settings.xml
[DEBUG] Using local repository at C:\Documents and Settings\desibaba\.m2\repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for C:\Documents and Settings\desibaba\.m2\repository
[INFO] Scanning for projects...
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://repo.maven.apache.org/maven2 via proxy.my-company.com:8080 as null
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.2/wagon-ssh-2.2.pom
[DEBUG] Writing resolution tracking file C:\Documents and Settings\desibaba\.m2\repository\org\apache\maven\wagon\wagon-ssh\2.2\wagon-ssh-2.2.pom.lastUpdated
[WARNING] The POM for org.apache.maven.wagon:wagon-ssh:jar:2.2 is missing, no dependency information available
[DEBUG] org.apache.maven.wagon:wagon-ssh:jar:2.2:
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:1.1:runtime
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://repo.maven.apache.org/maven2 via proxy.my-company.com:8080 as null
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.2/wagon-ssh-2.2.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[DEBUG] Writing resolution tracking file C:\Documents and Settings\desibaba\.m2\repository\org\apache\maven\wagon\wagon-ssh\2.2\wagon-ssh-2.2.jar.lastUpd
ated
[DEBUG] Writing resolution tracking file C:\Documents and Settings\desibaba\.m2\repository\org\codehaus\plexus\plexus-utils\1.1\plexus-utils-1.1.jar.last
Updated
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-ssh:2.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ssh:jar:2.2, org.codehaus.plexus:plexus-utils:jar:1.1: Could not find artifact org.apache.maven.wagon:wagon-ssh:jar:2.2 in central (http://repo.maven.apache.org/maven2) @

        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:363)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)
        at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR]
[ERROR]   The project xxx (C:\t1\9630727\pom.xml) has 1 error
[ERROR]     Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-ssh:2.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ssh:jar:2.2, org.codehaus.plexus:plexus-utils:jar:1.1: Could not find artifact org.apache.maven.wagon:wagon-ssh:jar:2.2 in central (http://repo.maven.apache.org/maven2) -> [Help 2]
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.wagon:wagon-ssh:2.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ssh:jar:2.2, org.codehaus.plexus:plexus-utils:jar:1.1: Could not find artifactorg.apache.maven.wagon:wagon-ssh:jar:2.2 in central (http://repo.maven.apache.org/maven2)
2012-04-05 17:39
by Desi Baba


13

I'm not able to do this with MVN 3.0.4 but I do with 3.0.3

It seems to be a bug in the 3.0.4 release.

The jira entry above gives a workaround for the maven 3.0.4 bug: add

<build>
    <extensions>
        <extension>
            <!-- this extension is required by wagon in order to pass the proxy -->
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http-lightweight</artifactId>
            <version>2.2</version>
        </extension>
    </extensions>
</build>

to your pom.xml

This worked for me

2012-05-16 19:04
by luciano.bustos
As codehaus doesn't exist anymore; MNG-5237 is now tracked here: https://issues.apache.org/jira/browse/MNG-523 - Sebastian J. 2017-03-06 14:26


9

Without touching your POM you can add this library to M2_HOME/lib/ext and use the following proxy settings into your settings.xml.

<proxy>
...
  <username>DOMAIN\USERNAME</username>
  <password>PASSWORD</password>
...

2013-07-10 07:43
by peterbrown
This workaround is useful for NTLM proxy for which there is a Maven bug linkpeterbrown 2013-07-10 07:45


4

Your settings file should look like the following:

<settings>
    <proxies>
        <proxy>
            <active>true</active>
            <protocol>http</protocol>
            <username><username-optional></username>
            <password><password-optional></password>
            <host><hostname></host>
            <port><port></port>
        </proxy>
    </proxies>
</settings>

If that's not working, then try putting your proxy settings into a browser like IE and see if it works. Also try hitting the proxy directly to ensure it's not a proxy configuration script. I don't know if maven plays well with those or not.

Though if it is a configuration script, the script should list out the correct proxy to use in your situation.

EDIT

I see you are working form conf/settings.xml where is that located? Normally the settings.xml file is located in:

/path/to/user/home/.m2/settings.xml

for you in windows that would be

C:\Documents and Settings\username\.m2\settings.xml

or

C:\users\username\.m2\settings.xml

or put it directly in your maven projects POM file.

2012-04-05 17:48
by Mike McMahon
For you in windows that would be "C:\Documents and Settings\desibaba.m2\settings.xml - j13r 2012-04-05 21:41
@j13r updated answer to include that as well - Mike McMahon 2012-04-05 21:48
umm I doubt if thats the case. If I remove the proxy from settings file, I get clear error that maven is unable to connect to repo. And after adding the proxy setting, it's not able to download the file. may be its my company proxy - Desi Baba 2012-04-06 01:01
@DesiBaba are you able to build the project when not behind the proxy? Are the definitions in your POM file correct - Mike McMahon 2012-04-06 17:28
@MikeMcMahon conf/settings.xml is located in->MAVEN_HOME/conf/settings which is used for global setting in maven. But user setting.xml can overwrite the global settings. in this case-> C:\Documents and Settings\desibaba.m2\settings.xm - jiming 2016-02-01 08:26


4

I tried introducing the proxy settings to the settings.xml file in several different locations, but it seems like none of them were picked up during runtime.

However, I discovered that there is an environment variable MAVEN_OPTS where I was finally able to set the proxy info and have it reflected at runtime:

MAVEN_OPTS
-Dhttp.proxyHost=proxy.myproxy.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=proxy.myproxy.com -Dhttps.proxyPort=80

Windows 7 System Variable Entry

2017-09-15 17:32
by Matsu Q.
This is the only solution which worked for me. That's so weird because all the settings.xml seem to be set up correctly - Kidburla 2018-01-16 20:47


3

use mvn -X to see reading order of settings.xml

use mvn help:effective-settings to see effective settings now

2014-05-11 03:19
by Trinea


2

I had similar problem. After adding nonProxyHosts

tag problem has been resolved. note that "zzz.zz.com" has to be replaced with your proper server.

<proxy>
...
...
 <nonProxyHosts>localhost|127.0.0.1|zzz.zz.com</nonProxyHosts>
...
...
</proxy>

for details http://maven.apache.org/guides/mini/guide-proxies.html

2014-09-16 07:25
by Ahmet Karakaya
Note: We have to add above elements in settings.xml available under 'user.home.m2' folder. If file doesn't exists already in the mentioned path, create it - Vijay Krish 2014-10-17 06:00


1

Excuse me for reviving such an old thread, but maybe this'll help someone having the same error.

I ran into the same problem as described by @OP. I combined some of the solution attempts described in here and it worked for me.

Brief problem description:

I've written a small chat program in java which worked fine. A few days later I got a new laptop at work and had to install and transfer everything. I used Eclipse (Version: Neon.2 Release (4.6.2)) on both of my laptops, the only difference was, that I used a Maven plugin for Eclipse on my old laptop and on the new one I installed Maven directly.

What did I do to solve the problem?

First, I wrote the proxy settings into settings.xml, as described in this proxy guide by Maven. It didn't work for me though.

NOTE: I changed the settings.xml under C:\Program Files\apache-maven-3.3.9\conf

Then I read the comment by @Vijay Krish

"Note: We have to add above elements in settings.xml available under 'user.home\.m2' folder. If file doesn't exists already in the mentioned path, create it."

There was no settings.xml so I just copied the one from C:\Program Files\apache-maven-3.3.9\conf to user.home\.m2 and tried again to run a Maven build and it worked fine.

I hope that this'll be useful for anyone struggling with this problem.

Best regards

2017-03-14 14:11
by Monterato


1

There are two settings.xml for maven depending on which settings.xml you are referring in your IDE .Make sure the proxy information is available in the one you are referring.

  1. One is available in .m2 directory
    C:\Users...m2\repository
  2. Other one is available in conf directory of the Maven folder.
    apache-maven-X.X.X

In my case the proxy information were being fetched from point no. 1 but i was trying to modify the the settings.xml in maven directory

2018-01-09 16:42
by Ripudaman Singh


0

I'm not sure if this is your problem but I noticed that I had to ensure that the https proxy came before http proxy in order to use an https proxy. It could be because they are the same hostname in my configuration.

2015-03-03 18:10
by Mark


0

If you are behind NTLM proxy, refer this solution that worked for me!

If you are using some IDE Like IntelliJ etc... please make sure you are changing settings.xml of the same maven which IDE uses! I mean there may be bundled Maven and if you change your system maven settings.xml it is obvious it won't work!So check IDE configurations.Please specify IDE name if you want more help on it.

Yes this one is silly but though worth to check out! check your system path environment variable for maven path which is exactly same of which settings.xml you are updating of.

hope this helps!

2016-01-25 07:45
by positivecrux
Ads