0

I'm tring to install Maven Wrapper and get "Error installing the Maven Wrapper.: Server returned HTTP response code: 401" from my Nexus Repository.

To reproduce the error I can just remove a local cache of Maven Wrapper and try to install it to an empty folder:

rm -R ~/.m2/repository/io/takari/maven-wrapper/0.5.6/
mvn -N io.takari:maven:wrapper -Dmaven=3.8.4

The output:

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven:0.7.7:wrapper (default-cli) @ standalone-pom ---
Downloading from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.pom
Downloaded from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.pom (2.4 kB at 15 kB/s)
Downloading from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Downloaded from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar (51 kB at 1.5 MB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.103 s
[INFO] Finished at: 2022-03-21T10:45:51+05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.takari:maven:0.7.7:wrapper (default-cli) on project standalone-pom: Error installing the Maven Wrapper.: Server returned HTTP response code: 401 for URL: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.tar.gz -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

pom and jar files are downloaded just fine. The problem is with tar.gz file only.

Here is my settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings
    xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

  <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>1</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <url>http://localhost:8081/repository/maven-public</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>

      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>

      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>

    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

The URL http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.tar.gz?describe is retrived just fine in a browser:

Code           200
Content-Type   application/x-gzip
Size           51848
Denis
  • 1,167
  • 1
  • 10
  • 30

1 Answers1

0

Error 401 is unauthorize error

Did you try to put an autologin config file in your user's home directory already?

Example: /Users/my_username/.netrc

machine nexus.somewhere.com
  login correct_user
  password correct_password

You also need to ensure the account is available and have valid permission to target lib