1

We have to work with Nexus OSS version 3.20.1-01. We have a problem with it when we try to deploy or push an Maven2 artifact(jar) to Nexus. We used a account test123 with password test123. test123 has privlidges nx-admin in nexus. If we try to login in the admin console we can do this without any problem.

But if we try to refer to a proxy server configured on Nexus with name sligro-proxy then for some reason its sends the 401.

We use Maven 3.5.4

But for some silly reason we can't use the proxy sligro-proxy to maven central. If we use Maven without Nexus by deleting the settings.xml file then this build goes fine. ./mvn package.

If I change something in the settings.xml file then I see the build is responding on that change.

We see the 401 in the request.log of Nexus like this:

192.168.178.123 - - [16/Feb/2020:19:46:50 +0100] "HEAD /nexus/repository/sligro-proxy/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom HTTP/1.1" 401 - 0 2 "Apache-Maven/3.5.4 (Java 1.8.0_112; Linux 3.10.0-957.27.2.el7.x86_64)" [qtp1998317514-191]    

And on the client we see this: [INFO] Finished at: 2020-02-16T19:46:50+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to nexus (http://192.168.178.178:8081/nexus/repository/sligro-proxy): Not authorized , ReasonPhrase: Unauthorized. -> [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/PluginResolutionException

This is my settings.xml file:

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>nexus-proxy</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
        </dependency>
    </dependencies>
    <distributionManagement>
        <repository>
            <id>sligro</id>
            <name>maven-releases</name>
            <url>http://192.168.178.178:8081/nexus/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>sligro</id>
            <name>maven-snapshots</name>
            <url>http://192.168.178.178:8081/nexus/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>```

This is my settings.xml file:

    </project>This is my settings file:<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <proxies/>
    <servers>
        <server>
            <id>nexus-snapshots</id>
            <username>test123</username>
            <password>test123</password>
        </server>
        <server>
            <id>nexus-releases</id>
            <username>test123</username>
            <password>test123</password>
        </server>
        <server>
            <id>sligro</id>
            <username>test123</username>
            <password>test123</password>
        </server>
        <server>
            <id>sligro-proxy</id>
            <username>test123</username>
            <password>test123</password>
        </server>
        <server>
            <id>/192.168.178.178:8081</id>
            <username>test123</username>
            <password>test123</password>
        </server>
    </servers>
    <mirrors>
        <mirror>
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://192.168.178.178:8081/nexus/repository/sligro-proxy</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>sligro</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>
            <properties>
                <nexus.url>http://192.168.178.178:8081/nexus/repository</nexus.url>
            </properties>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>sligro</activeProfile>
    </activeProfiles>
</settings>    



Well I almost spend to 2 days this weekend to find out what the problem is and 
changed tons of params but it gives always the 401. Help would be appriciated. 
Thanks
Ben
  • 594
  • 1
  • 9
  • 24

1 Answers1

1

I have found the solution. My mirror has the wrong ID. If I use the "sligro" ID instead of the "nexus" ID in the mirrors section then the Maven build to nexus runs fine.

Ben
  • 594
  • 1
  • 9
  • 24