Maven 401 unauthorized when deploying on archiva

1.9k views Asked by At

I'm getting a "401 unauthorized" error from Apache Archiva repository when I try to deploy from a Maven build.

When using Maven 3.1.1 or lower it's working fine, I can deploy snapshots or releases on the Archiva repo. As soon as i'm using Maven 3.2.1 or greater, it's not working anymore. By looking at the release notes I could not figure out what could cause that.

  • Downloading from the repo is fine
  • Uploading on the repo results in 401 unauthorized
  • The users are declared in the settings.xml file in the .m2 folder
  • No proxy settings

Here is the debug trace of the deploy that's failing :

[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ Xplugin ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=0, ConflictMarker.nodeCount=32, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=14, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=0, ConflictResolver.conflictItemCount=32, DefaultDependencyCollector.collectTime=3, DefaultDependencyCollector.transformTime=0}
[DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.7:
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0.6:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-settings:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0.6:compile
[DEBUG]          org.apache.maven:maven-repository-metadata:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.0.6:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG]          junit:junit:jar:3.8.1:compile
[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG]    org.apache.maven:maven-model:jar:2.0.6:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.0.6:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:1.5.6:compile
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG]   Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
[DEBUG]   Included: junit:junit:jar:3.8.1
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:1.5.6
[DEBUG]   Excluded: org.apache.maven:maven-plugin-api:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-project:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-settings:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-profile:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-artifact-manager:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-repository-metadata:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-plugin-registry:jar:2.0.6
[DEBUG]   Excluded: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1
[DEBUG]   Excluded: classworlds:classworlds:jar:1.1-alpha-2
[DEBUG]   Excluded: org.apache.maven:maven-model:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-artifact:jar:2.0.6
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7, parent: sun.misc.Launcher$AppClassLoader@55f96302]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy' with basic configurator -->
[DEBUG]   (f) artifact = com.application.pdfplugins:Xplugin:jar:3.1.0-00-SNAPSHOT
[DEBUG]   (f) attachedArtifacts = []
[DEBUG]   (s) localRepository =       id: local
      url: file:///C:/Users/bamboo/.m2/repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG]   (f) offline = false
[DEBUG]   (f) packaging = jar
[DEBUG]   (f) pomFile = C:bamboo\xml-data\build-dir\26771457\PDFPLUGINS-XAS4-JOB1\Xplugin\dependency-reduced-pom.xml
[DEBUG]   (f) project = MavenProject: com.application.pdfplugins:Xplugin:3.1.0-00-SNAPSHOT @ C:bamboo\xml-data\build-dir\26771457\PFPLUGIN-X-JOB1\Xplugin\dependency-reduced-pom.xml
[DEBUG]   (f) retryFailedDeploymentCount = 1
[DEBUG]   (f) skip = false
[DEBUG]   (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://maven-dev.org/repository/built-artifacts/
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://maven-dev.org/repository/built-artifacts/ with username=writer, password=***
[INFO] Downloading: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/maven-metadata.xml
[INFO] Downloaded: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/maven-metadata.xml (390 B at 11.5 KB/sec)
[DEBUG] Writing tracking file C:\Users\bamboo\.m2\repository\com\application\pdfplugins\Xplugin\3.1.0-00-SNAPSHOT\resolver-status.properties
[INFO] Uploading: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar
[INFO] Uploading: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:06 min
[INFO] Finished at: 2018-06-04T17:21:36+02:00
[INFO] Final Memory: 39M/592M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project Xplugin: Failed to deploy artifacts: Could not transfer artifact com.application.pdfplugins:Xplugin:jar:3.1.0-00-20180604.152136-4 from/to built-artifacts (https://maven-dev.org/repository/built-artifacts/): Failed to transfer file: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project Xplugin: Failed to deploy artifacts: Could not transfer artifact com.application.pdfplugins:Xplugin:jar:3.1.0-00-20180604.152136-4 from/to built-artifacts (https://maven-dev.org/repository/built-artifacts/): Failed to transfer file: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar. Return code is: 401, ReasonPhrase: Unauthorized.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact com.application.pdfplugins:Xplugin:jar:3.1.0-00-20180604.152136-4 from/to built-artifacts (https://maven-dev.org/repository/built-artifacts/): Failed to transfer file: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar. Return code is: 401, ReasonPhrase: Unauthorized.
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact com.application.pdfplugins:Xplugin:jar:3.1.0-00-20180604.152136-4 from/to built-artifacts (https://maven-dev.org/repository/built-artifacts/): Failed to transfer file: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar. Return code is: 401, ReasonPhrase: Unauthorized.
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
    ... 21 more
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact com.application.pdfplugins:Xplugin:jar:3.1.0-00-20180604.152136-4 from/to built-artifacts (https://maven-dev.org/repository/built-artifacts/): Failed to transfer file: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar. Return code is: 401, ReasonPhrase: Unauthorized.
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:317)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:245)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
    ... 23 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.application.pdfplugins:Xplugin:jar:3.1.0-00-20180604.152136-4 from/to built-artifacts (https://maven-dev.org/repository/built-artifacts/): Failed to transfer file: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar. Return code is: 401, ReasonPhrase: Unauthorized.
    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector.put(BasicRepositoryConnector.java:274)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:311)
    ... 26 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://maven-dev.org/repository/built-artifacts/com/application/pdfplugins/Xplugin/3.1.0-00-SNAPSHOT/Xplugin-3.1.0-00-20180604.152136-4.jar. Return code is: 401, ReasonPhrase: Unauthorized.
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:642)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:557)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:539)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:533)
    at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:513)
    at org.eclipse.aether.transport.wagon.WagonTransporter$PutTaskRunner.run(WagonTransporter.java:644)
    at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
    at org.eclipse.aether.transport.wagon.WagonTransporter.put(WagonTransporter.java:410)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PutTaskRunner.runTask(BasicRepositoryConnector.java:510)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
    ... 28 more
[ERROR] 
[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
Failing task since return code of [C:\Maven_3.2.5\bin\mvn.bat --batch-mode -Djava.io.tmpdir=D:\Apps\Bamboo\temp\PDFPLUGINS-XAS4-JOB1 -e -Xclean package deploy -DskipTests=true] was 1 while expected 0

As you can see the username and password are correctly retrieved by maven (username=writer, password=***) but I get the 401 anyway.

The only difference that I could see between Maven 3.1.1 and 3.2.1 is that the first is using "WagonRepositoryConnector" and the second is using "BasicRepositoryConnector" I searched for the differences between the two or how could I force Wagonrepositoryconnector but did no find relevant information.

Does somebody have an idea of what could prevent version 3.2.1 and greater to deploy the artifacts? it looks like the credentials are messed up with the newer versions of Maven.

EDIT 1

After further debug i was able to understand that the faulty component was "wagon-http" which is upgraded to v 2.6 in Maven 3.2.1.

Specifying the wagon-http to use in the pom.xml is the only workaround I could find for the moment : in the pom.xml inside the build section i added :

<extension>
    <groupId>org.apache.maven.wagon</groupId> 
    <artifactId>wagon-http</artifactId> 
    <version>2.5</version>
  </extension>
</extensions>

It's the last version working.

In the Wagon 2.6 release note there is "Upgrade Apache HttpClient based wagon provider to HttpClient 4.3". I suspect that the problem lies here so I tried a few things :

  • I disabled all the SSL security (even if there were no SSL error message but you never know it can be wrapped in a 401 unauthorized with no further explanation) but it still failed.
  • I disabled the authentication on my repository and I was able to upload the artifact

This last statement makes me think that the authentication is mishandled by the httpclient 4.3 (or maybe another component of wagon-http).

I don't understand what could cause this, if somebody has something to try I'll be glad to test it.

0

There are 0 answers