2

当我尝试从 Maven 构建进行部署时,我从 Apache Archiva 存储库中收到“ 401 未授权”错误。

当使用Maven 3.1.1或更低版本时它工作正常,我可以在 Archiva 存储库上部署快照或发布。一旦我使用Maven 3.2.1或更高版本,它就不再工作了。通过查看发行说明,我无法弄清楚是什么原因造成的。

  • 从 repo 下载没问题
  • 在 repo 上上传会导致 401 未经授权
  • 用户在 .m2 文件夹的 settings.xml 文件中声明
  • 没有代理设置

这是失败的部署的调试跟踪:

[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

如您所见,maven (username=writer, password=***) 正确检索了用户名和密码,但我还是得到了 401。

我在 Maven 3.1.1 和 3.2.1 之间看到的唯一区别是第一个使用“ WagonRepositoryConnector ”,第二个使用“ BasicRepositoryConnector ”我搜索了两者之间的差异或者我如何强制 Wagonrepositoryconnector 但没有查找相关信息。

有人知道什么会阻止 3.2.1 及更高版本部署工件吗?看起来凭据与较新版本的 Maven 混淆了。

编辑 1

经过进一步调试,我能够理解故障组件是“ wagon-http ”,它在 Maven 3.2.1 中升级到 v 2.6

指定要在 pom.xml 中使用的 wagon-http 是目前我能找到的唯一解决方法:在我添加的构建部分的 pom.xml 中:

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

这是最后一个版本。

Wagon 2.6 发行说明中有“将基于 Apache HttpClient 的 wagon 提供程序升级到 HttpClient 4.3 ”。我怀疑问题出在这里,所以我尝试了一些方法:

  • 我禁用了所有 SSL 安全性(即使没有 SSL 错误消息,但您永远不知道它可以包装在未经授权的 401 中,无需进一步解释),但它仍然失败。
  • 我在我的存储库上禁用了身份验证,并且能够上传工件

最后这句话让我认为 httpclient 4.3(或者 wagon-http 的另一个组件)对身份验证处理不当。

我不明白是什么原因造成的,如果有人有什么可以尝试的,我会很高兴测试它。

4

0 回答 0