[GRADLE-2233] Bug in HttpClient 4.1.2 causes issues with proxies Created: 13/Apr/12  Updated: 06/Feb/17  Resolved: 06/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 1


 Description   

Hi All,

I am unable to connect maven repo by using proxy setting
I have added maven dependency in my build file
repositories

{ mavenCentral() }

dependencies

{ compile group: 'commons-collections', name: 'commons-collections', version: '3.2' testCompile group: 'junit', name: 'junit', version: '4.+' }

and also added proxy configuration in the gradle.properties
systemProp.proxySet=true
systemProp.http.proxyHost=myproxy.com
systemProp.http.proxyPort=80
systemProp.http.proxyUser=myusername
systemProp.http.proxyPassword=myuserpass

when i run the build i am getting the following error
Proxy authentication error: Invalid name provided (Mechanism level: Could not lo
ad configuration file C:\WINDOWS\krb5.ini (The system cannot find the file speci
fied))
Proxy authentication error: Invalid name provided (Mechanism level: Could not lo
ad configuration file C:\WINDOWS\krb5.ini (The system cannot find the file speci
fied))
Proxy authentication error: Invalid name provided (Mechanism level: Could not lo
ad configuration file C:\WINDOWS\krb5.ini (The system cannot find the file speci
fied))

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all dependencies for configuration ':testRuntime'.
    > Could not resolve group:commons-collections, module:commons-collections, versi
    on:3.2.
    Required by:
    com.winter:sample:0.0.1-SNAPSHOT
    > Could not GET '[1]http://repo1.maven.org/maven2/commons...
    llections/3.2/commons-collections-3.2.pom'. Received status code 407 from server
    : Proxy Authentication Required
    > Could not resolve group:junit, module:junit, version:4.+.
    Required by:
    com.winter:sample:0.0.1-SNAPSHOT
    > Could not GET '[2]http://repo1.maven.org/maven2/junit/j...
    '. Received status code 407 from server: Proxy Authentication Required


 Comments   
Comment by Gradle Forums [ 13/Apr/12 ]

Sounds like [1]http://stackoverflow.com/questions/57.... Apache HTTPClient is what Gradle uses underneath. Have you tried with the latest Gradle version (1.0-milestone-9)? There have recently been some related changes.
----------------------------------------------------------------------------------------
[1] http://stackoverflow.com/questions/5746545/apache-httpclient-4-1-1-ntlm-authentication-not-spnego

Comment by Gradle Forums [ 13/Apr/12 ]

I am using Gradle 1.0-milestone-9 for this

------------------------------------------------------------
Gradle 1.0-milestone-9
------------------------------------------------------------

Gradle build time: Tuesday, March 13, 2012 4:10:09 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_23 (Sun Microsystems Inc. 19.0-b09)
OS: Windows XP 5.1 x86

Comment by Gradle Forums [ 13/Apr/12 ]

Is there any work around for this?

Comment by Gradle Forums [ 13/Apr/12 ]

One thing worth trying is to replace lib\plugins\httpclient-4.1.2.jar and httpcore-4.1.2.jar in the Gradle distribution with the Jars extracted from [1]http://www.reverse.net/pub/apache//ht.... Make sure to rename the new Jars to the old filenames. If that doesn't help, we'll need to do a deeper investigation, which might take a while.
----------------------------------------------------------------------------------------
[1] http://www.reverse.net/pub/apache//httpcomponents/httpclient/binary/httpcomponents-client-4.2-beta1-bin.zip

Comment by Gradle Forums [ 13/Apr/12 ]

magical.
Thank you.
The proxy settings stopped working from gradle milestone 5 ...!!!

Comment by Gradle Forums [ 13/Apr/12 ]

For many users, proxy settings work fine. I haven't heard of this problem before. We needed to update the HttpClient library to get around other problems. Judging from your feedback, the next update (once HttpClient 4.2 has been released) will solve your problem. Thanks for letting us know.

Comment by Peter Niederwieser [ 13/Apr/12 ]

We should update to 4.2 immediately after it's out, or update to a beta. Here is the issue: https://issues.apache.org/jira/browse/HTTPCLIENT-1139

Comment by Martin Flower [ 19/Jun/12 ]

I've just run into this problem using gradle 1.0 - this seems to come with HttpClient 4.1.2. instead of 4.2. 4.2 Appears to be GA.

Comment by Martin Flower [ 19/Jun/12 ]

I've swapped in 4.2 jars instead of 4.1.2, renamed them to 4.1.2. Same problem.

Comment by Adam Murdoch [ 19/Aug/12 ]

Can you try using Gradle 1.1, and let us know if this is still an issue for you? Thanks.

Comment by Martin Flower [ 20/Aug/12 ]

I have since moved on to another project. I have just now briefly tried to reproduce the problem using Gradle 1.1, and failed. So maybe the problem can be considered fixed ? Thanks. /Martin.

Comment by Adam Adamaszek [ 04/Feb/14 ]

sadly, it seems the issue still persists for us, with 1.11-rc2 and httpClient 4.3.2

If I patch gradle's HttpClientConfigurer.java:83 from

httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM, AuthPolicy.NTLM), ntCredentials);

to

httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM, AuthPolicy.BASIC), ntCredentials);

It works with our proxy (the dreaded McAfee Web Gateway).

Can you make AuthPolicy configurable? I'd be happy to submit a pull request...

Comment by Adam Murdoch [ 05/Feb/14 ]

@Adam, we'd welcome a pull request. It might be worth discussing the change first on the dev mailing list, as I'd like to look into whether we can make things just work rather than adding another magic property to select the authentication scheme.

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Adam Adamaszek [ 15/Nov/16 ]

Gradle 3.1 is still not able to go out through McAfee proxies, so I can confirm we would benefit from this being fixed.

Comment by Benjamin Muschko [ 06/Feb/17 ]

Gradle 3.3 is using HttpClient version 4.4.1. Based on the HttpClient issue 1139 this should be fixed. If it isn't fixed yet then it might simply be an issue with HttpClient. Given the low number of votes for the issue we are not planning to pursue a fix. Please open an issue on GitHub if a fix is crucial to your environment. We will likely ask you to provide a pull request.

Generated at Wed Jun 30 12:16:22 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.