3

I run mvn archetype:generate and get this error:

Error reading archetype catalog http://repo.maven.apache.org/maven2
org.apache.maven.wagon.TransferFailedException: Transfer failed for http://repo.maven.apache.org/maven2 501 HTTPS Required

I'm using Maven 3.6.3.

I cannot put a different repository URL into the POM file, because when I'm creating a project from an archetype, no POM file exists yet.

I have no settings.xml file in ~/.m2.

Is there something wrong with my Maven installation?


The output of mvn --version is:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 11.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"

/usr/local/Cellar/maven/3.6.3_1/libexec/conf/settings.xml does not contain the URL that the error message is complaining about.

mistercake
  • 692
  • 5
  • 14
  • I doubt that you have no `settings.xml` ... do you use plain command line? Can you make a `mvn --version` and post what the output is? – khmarbaise Apr 25 '20 at 11:24
  • Not in `~/.m2`. I use the plain command line. I added the requested information. – mistercake Apr 25 '20 at 11:39
  • 1
    Running with ```-X``` might give you a clue as to which configuration is used. – Pieterjan Deconinck Apr 25 '20 at 13:08
  • Maven was using an old version of the archetype plugin. When I explicitly specify a newer version, it works. – mistercake Apr 26 '20 at 07:06
  • This question has already been answered at https://stackoverflow.com/questions/59763531/maven-dependencies-are-failing-with-a-501-error – John Manko May 07 '20 at 15:34
  • Does this answer your question? [Maven dependencies are failing with a 501 error](https://stackoverflow.com/questions/59763531/maven-dependencies-are-failing-with-a-501-error) – John Manko May 07 '20 at 15:35
  • No really, since I am using a Maven version that supposedly already knows about the HTTPS URLs. Why does Maven use an old version of the archetype plugin by default? Is this configured somewhere? – mistercake May 08 '20 at 16:31

1 Answers1

3

Short answer: override the default http catalog url with an https one, by appending:

-DarchetypeCatalog=https://repo.maven.apache.org/maven2/archetype-catalog.xml

to the mvn archetype:generate command

Background:

When using the mvn -X -e archetype:generate command, Maven 3.6.3 seems to use version 2.4 of the maven-archetype-plugin:

[DEBUG] Resolved plugin version for org.apache.maven.plugins:maven-archetype-plugin to 2.4 from repository central (https://repo.maven.apache.org/maven2, default, releases)

The plugin uses the remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml:

[DEBUG] Searching for remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml
[DEBUG] Searching for remote catalog: http://repo.maven.apache.org/maven2
[WARNING] Error reading archetype catalog http://repo.maven.apache.org/maven2
org.apache.maven.wagon.TransferFailedException: Transfer failed for http://repo.maven.apache.org/maven2 501 HTTPS Required

As of 15/1/2020, maven central requires an HTTPS url: Central 501 HTTPS Required

According to this JIRA, the issue should be fixed in version 3.0.0 of the plugin.

tanderson
  • 1,169
  • 12
  • 29