gradlegitlabdependency-managementhttp-proxy

Gradle gets 503 Service Unavailable trying to download dependency


My gradle project uses internal company artifact registry and mavenCentral(). I need to make it work on new computer, with Gradle upgraded from 7.3 to 8 version and on strict company policy where internet coonnection goes through company internet proxy.

The gradle build which used to be working on old configuration suddenly stopped working with error:

Execution failed for task ':app:generateJavaClasses'.
> Could not resolve all files for configuration ':app:jaxb'.
   > Could not resolve org.glassfish.jaxb:jaxb-core:2.3.0.1.
     Required by:
         project :app
      > Repository GitLab is disabled due to earlier error below:
         > Could not resolve org.glassfish.jaxb:jaxb-xjc:4.0.5.
            > Could not get resource 'https://our-registry.our-company/api/v4/projects/21/packages/maven/org/glassfish/jaxb/jaxb-xjc/4.0.5/jaxb-xjc-4.0.5.pom'.
               > Could not GET 'https://our-registry.our-company/api/v4/projects/21/packages/maven/org/glassfish/jaxb/jaxb-xjc/4.0.5/jaxb-xjc-4.0.5.pom'. Received status code 503 from server: Service Unavailable

The purpose of our-registry is to provide our artifacts. It actually does not contain the JAXB artifact. The registry intentionally precedes mavenCentral(). I am not surprised our registry can't finding the JAXB artifact but I expect it to shift to next repository (mavenCentral) on error.

Instead it fails with HTTP 503 error. The repository works ok (confirmed by maintaining engineers). What's going on here?


Solution

  • The problem was wrong internet proxy settings. I have setup system variable systemProp.http.proxyHost=internet-proxy.our-company in .gradle.properties but forgot to set variable systemProp.http.nonProxyHosts to 127.0.0.1|localhost|*.our-company|docker. Since the our-registry.our-company is an intranet site, it must be excluded from internet proxy. The proxy returns 503 error on attempt of access intranet site, the 503 does not come from registry.

    The problem is easy to discover with gradle --debug option where 2024-09-06T15:14:46.317+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] CONNECT refused by proxy: HTTP/1.1 503 Service Unavailable appears.

    Also it's worth noting that expecting fallback to next repository on 503 error is against the gradle philosophy of build reproducibility. It is explained here in further detail.