Image showing [SOLVED] Maven dependencies are failing with a 501 error

[SOLVED] Maven dependencies are failing with a 501 error

affiliate best offer

I have a jekins installation on my infrastructure. I found that recently my maven jobs are failing with an exception saying that they couldn’nt pull dependencies. Here is how I solved it.

TL;DR

The quick answer is that I didn’t read the warning from maven team saying that HTTPS is now required.

As of January 15, 2020 I am receiving the following responses upon making requests to The Central Repository:

Requests to http://repo1.maven.org/maven2/ return a 501 HTTPS Required status and a body:

501 HTTPS Required. Use https://repo1.maven.org/maven2/ More information at https://links.sonatype.com/central/501-https-required

Requests to http://repo.maven.apache.org/maven2/ return a 501 HTTPS Required status and a body:

501 HTTPS Required. Use https://repo.maven.apache.org/maven2/ More information at https://links.sonatype.com/central/501-https-required

I should have read that notice :p

My configuration and the error I was having, in details

I am using maven 3.6.0 on Ubuntu 18.04.

Here is the error I was getting.

[ERROR] Unresolveable build extension:
Plugin org.apache.maven.wagon:wagon-ssh:2.1 or one of its dependencies could not be resolved:
Failed to collect dependencies for org.apache.maven.wagon:wagon-ssh:jar:2.1 ():
Failed to read artifact descriptor for org.apache.maven.wagon:wagon-ssh:jar:2.1:
Could not transfer artifact org.apache.maven.wagon:wagon-ssh:pom:2.1 from/to central (http://repo.maven.apache.org/maven2):
Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom.
Return code is: 501, ReasonPhrase:HTTPS Required. -> [Help 2]

Waiting for Jenkins to finish collecting data[ERROR]
Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1:
Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to central (http://repo.maven.apache.org/maven2):
Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom.
Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]

The solution

To solve this problem, I did some replacements of the maven urls in my configuration.

Replace http://repo1.maven.org/maven2 with https://repo1.maven.org/maven2 (notice the https)

Replace http://repo.maven.apache.org/maven2 with https://repo.maven.apache.org/maven2

In case you cannot use https

In case you cannot use the secure connection https, there is a dedicated insecure endpoint you can use :

http://insecure.repo1.maven.org/maven2

Final thoughs

I hope this article helped solving your issue on Maven dependencies are failing with a 501 error.

You might also like these blog posts

Full Bright

Full Bright

A professional and sympathic business man.

Contact

Contact Us

Not sure which of these you need? Book the free 20-minute audit — we look at one week of your work and tell you what is worth automating, what is not, and what it would cost. Book it here.

One audit call a week, Thursdays or Fridays — book early if a specific day matters to you.

Address

10 rue François 1er,
75008 Paris

When we work

Monday - Friday
9:00AM - 05:00PM