Not being able to download dependencies from mavencentral from behind a corporate proxy, on ntlm


(Partha Bhattacharjee) #1

Hi,

I am using jdk 1.7, gradle 1.3

I have a /gradle.properties file at the root folder of my project i.e. at C:\partha\codeRepo\gradle002\gradle.properties, where gradle002 is my java project.

systemProp.http.proxyHost = Name of proxy. The one that works with Maven systemProp.http.proxyPort = 8080 systemProp.http.proxyUser = domain/username. These work with Maven as well.

When I run clean (or any other command) expectedly gradle tries to download dependencies from mavencentral. My buil.gradle looks like this

// Java plugin to build our JAR artifact. apply plugin: ‘java’

// Build stuff with jdk 1.7 sourceCompatibility = 1.7 targetCompatibility = 1.7

// Regular name and version for your project.

group = ‘foo.bar.gradle’ version = ‘1.0-SNAPSHOT’

// The local maven repository def localMavenRepo = ‘file://C:/ProgramFiles/MavenRepository’

repositories {

// Use the maven central repository.

mavenCentral()

// … and the local maven repository.

maven { url localMavenRepo }

// maven { url ‘http://www.springsource.com/repository/’ } }

dependencies {

compile ‘org.databene:contiperf:2.2.0’,‘org.springframework:spring-webmvc:3.2.1.RELEASE’

testCompile ‘junit:junit:4.11’

/compile.exclude module: ‘commons’/

/all.exclude*/

}

But all I get is

NEGOTIATE authentication error: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt))

for each dependency and I have checked in the local repository folder, the dependency are not downloaded.

So, net net, on gradle 1.3, behind a proxy, using NTLM, I am not able to download dependencies. It warrants mention that if I download the dependencies via Maven, and then try and execute the build and release using gradle, it is working alright. But I need to have a gradle only solution, cause I am trying to evangelize gradle in my organization.

I have reached out at http://stackoverflow.com/questions/14434101/gradle-not-working-behind-proxy-with-ntlm-on-windows as well.

Please help.


Running Gradle through an NTLM proxy
#2

Can you please try with Gradle-1.4-rc-3?

This has an updated version of commons http client and may fix your NTLM authentication problems.


(Partha Bhattacharjee) #3

Thanks for responding so quickly.

Nope. No luck. I am still getting the same issues with the same settings. Although it appears to be failing a bit faster.

Another bit of data that might help you guys. I am seeing this response in STS.

Could not GET ‘http://repo1.maven.org/maven2/org/springframework/spring-webmvc/3.2.1.RELEASE/spring-webmvc-3.2.1.RELEASE.pom’. Received status code 500 from server: Internal Server Error Could not execute build using Gradle installation ‘C:\ProgramFiles\gradle-1.4-rc-3’.

And before you say there is something wrong with the proxy - I don’t think so - I just ran Maven on the same proxy using the same settings and it worked perfectly alright.


#4

Damn I was hoping that you were hitting GRADLE-2650. NTLM authentication is very difficult for us to test, so we rely on users like yourself to help us track down issues.

Can you please supply the full output of running:

// Any task that forces dependencies to be resolved will do
gradle --refresh-dependencies --debug compileJava

The best way to provide log output is via a pastebin service like GitHub Gist.

PS In future please wrap any code or output in HTML-style ‘< code >’ tags. This makes the posting much easier to read.


(Partha Bhattacharjee) #5

Ok. I have run the command and got the logs. However, there is significant amount of cleaning required on the logs (which contains confidential data e.g. actual proxy name etc).

I did a bit of digging around myself. Here are a few lines that raise suspicion.

...
10:41:44.499 [DEBUG] [org.apache.http.impl.client.SystemDefaultHttpClient] Selected authentication options: [NEGOTIATE, NTLM, BASIC]
...
10:41:44.670 [DEBUG] [org.apache.http.client.protocol.RequestProxyAuthentication] Generating response to an authentication challenge using Negotiate scheme
...
10:41:46.983 [WARN] [org.apache.http.client.protocol.RequestProxyAuthentication] NEGOTIATE authentication error: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt))
...
10:41:46.983 [DEBUG] [org.apache.http.client.protocol.RequestProxyAuthentication] Generating response to an authentication challenge using ntlm scheme
...
10:41:47.296 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 500 Internal Server Error
10:41:47.296 [DEBUG] [org.apache.http.headers] << HTTP/1.1 500 Internal Server Error
...

The log then goes onto say that authentication succeeded, but of course it had already sent back a " HTTP/1.1 500" to my project. And that is the source of the error message (not necessarily the error though).

Once it has authenticated, it fails to find the stuff to download. It fails to find that in my local repository because the folder name is all wrong.

...
10:41:47.327 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Loading C:\ProgramFiles\MavenRepository/org/springframework/spring-webmvc/3.2.1.RELEASE/spring-webmvc-3.2.1.RELEASE.pom
...

I think this is where it messes up. Notice how it is looking in the wrong folder. C:…/…/. The slashes are all wrong.

However my build.gradle has it right.

...
// The local maven repository
def localMavenRepo = 'file://C:/ProgramFiles/MavenRepository'
...

Did someone hardcode the slashes for unix systems?


#6

I think the problem is that ‘localMavenRepo’ is not a valid file URL. Your best best is probably to try something like:

repositories {
      maven {
            url file('C:\ProgramFiles\MavenRepository')
     }
}

(Partha Bhattacharjee) #7

Nope. No luck.


(Gopal Dangi) #8

I have also same problem after setting proxy.

Error | [main] WARN org.apache.http.client.protocol.RequestProxyAuthentication - NEGOTIATE authentication error: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt))