Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven behind a auto-generated proxy

Tags:

proxy

maven

I'm behind a auto-generated proxy.

I've configured my settings.xml to use this proxy, but it still doesn't work. The Android SDK works fine with the same proxy which I've set.

<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
                  http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <proxies>
    <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <username></username>
        <password></password>
        <host>MY-PROXY-HOST-HERE</host>
        <port>8080</port>
        <nonProxyHosts></nonProxyHosts>
    </proxy>
  </proxies>
</settings>

What else can I do to make maven to work?

Error:

WARNING: NTLM authentication error: Credentials cannot be used for NTLM authenti
cation: org.apache.maven.wagon.providers.http.httpclient.auth.UsernamePasswordCr
edentials

How to get my NTLM authentication credintals?


Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Not authorized by proxy , ReasonPhrase:Proxy Authorization Required.

This is the output message. In my wpad.dat (from where I've taken proxy data), I don't have a specified username and password...

like image 819
Sorin Vladu Avatar asked May 08 '14 10:05

Sorin Vladu


2 Answers

credentials are not the solution!

Solution to your problem is cntlm

steps to go

First step -->

Steps to get rid of these NTLM proxy Issues permanently.

  1. download and install cntlm
  2. edit cntlm.ini file in cntlm installation directory and make sure there is proxy of your network i.e. "Proxy NTLMPROXYHOST:PORT" e.g. Proxy 192.168.0.1:8080 (this is your network proxy from which you access internet!)
  3. DO NOT FORGET TO PUT your windows authentication credentials in cntlm.ini file just put your windows username ,your domain name ,your password .
  4. create environment variable(system variable) named CYGWIN with value "nodosfilewarning"(without quotes) if you don't do so you are not able to even start cntlm! Secondly make two environment variables named http_proxy with value "http://localhost:3128" and https_proxy with value "http://localhost:3128".
  5. go to start menu and click on cntlm folder then click on "start cntlm authentication proxy"(DO NOT FORGET TO MAKE "start cntlm authentication proxy" SHORTCUT A STARTUP PROGRAM OTHERWISE YOU CAN NOT ACCESS INTERNET AFTER REBOOT!! OR YOU NEED TO MANNUALLY START CNTLM PROXY EVERY TIME YOU REBOOT!!).
  6. open internet explorer --> Tools --> Internet Options --> Connections --> LAN settings
  7. tick mark both the checkbox under "proxy server" heading.
  8. put localhost or 127.0.0.1 in "address" text box and put 3128 under "port" text box(yes! you do not need your network proxy anymore as we already kept in cntlm.ini).
  9. click ok then again ok then close IE.

Thats it!! now you never see error related to NTLM proxy authentication failed or anything else not even in sbt or maven!!! CNTLM is quite fast as it is developed in C !!

Second step -->

start cntlm authentication proxy server

make sure your settings.xml file's proxy look like this.

  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |-->
    <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>127.0.0.1</host>
      <port>3128</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
  </proxies>

Plese give me feedback if something does not work!

like image 118
positivecrux Avatar answered Oct 18 '22 04:10

positivecrux


I've found a working solution on codepen.io. You simply put a wagon-http-lightweight jar into Maven lib/ext folder.

like image 25
xuesheng Save Ukraine Avatar answered Oct 18 '22 02:10

xuesheng Save Ukraine