Eclipse 中的 Maven Bintray 分发不上传 jar 文件。错误码401(未授权)但只针对jar包?

Maven Bintray distribution in Eclipse is not uploading jar files. Error code 401 (Unauthorized) but only for jar packaging?

我正在尝试将项目部署到 Maven 到 bintray,它成功上传了 pom 文件,但是 returns 上传 jar 文件时出现错误代码 401。

我已经完成了 bintray 教程,正确设置了我的 settings.xml,在我的 pom 文件中添加了正确的 distributionManagement 等字段,确保该项目不是快照等,但似乎无法获得上传 jar 文件有效吗?我一直在试图弄清楚可能发生了什么,但没有成功。

有关堆栈跟踪 pom.xml、settings.xml 和 eclipse 配置的详细信息如下。整个项目可以在 github

上找到

我是不是遗漏了什么明显的东西?非常感谢任何帮助。

[DEBUG]   (f) packaging = jar
[DEBUG]   (f) pomFile = /Users/au671271/git/pytorch2java/PyTorch2Java/pom.xml
[DEBUG]   (s) skip = false
[DEBUG]   (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[INFO] Installing /Users/au671271/git/pytorch2java/PyTorch2Java/target/jtorch4pam-0.0.63.jar to /Users/au671271/.m2/repository/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar
[DEBUG] Writing tracking file /Users/au671271/.m2/repository/org/jamdev/jtorch4pam/0.0.63/_remote.repositories
[INFO] Installing /Users/au671271/git/pytorch2java/PyTorch2Java/pom.xml to /Users/au671271/.m2/repository/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.pom
[DEBUG] Writing tracking file /Users/au671271/.m2/repository/org/jamdev/jtorch4pam/0.0.63/_remote.repositories
[DEBUG] Installing org.jamdev:jtorch4pam/maven-metadata.xml to /Users/au671271/.m2/repository/org/jamdev/jtorch4pam/maven-metadata-local.xml
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ jtorch4pam ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=75304, ConflictMarker.markTime=31640, ConflictMarker.nodeCount=32, ConflictIdSorter.graphTime=78145, ConflictIdSorter.topsortTime=17029, ConflictIdSorter.conflictIdCount=14, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=349870, ConflictResolver.conflictItemCount=32, DefaultDependencyCollector.collectTime=7611621, DefaultDependencyCollector.transformTime=581161}
[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] 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: jdk.internal.loader.ClassLoaders$AppClassLoader@55054057]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy' with basic configurator -->
[DEBUG]   (f) artifact = org.jamdev:jtorch4pam:jar:0.0.63
[DEBUG]   (f) attachedArtifacts = []
[DEBUG]   (s) localRepository =       id: local
      url: file:///Users/au671271/.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 = /Users/au671271/git/pytorch2java/PyTorch2Java/pom.xml
[DEBUG]   (f) project = MavenProject: org.jamdev:jtorch4pam:0.0.63 @ /Users/au671271/git/pytorch2java/PyTorch2Java/pom.xml
[DEBUG]   (f) retryFailedDeploymentCount = 1
[DEBUG]   (f) skip = false
[DEBUG]   (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[DEBUG] Using connector AetherRepositoryConnector with priority 100.0 for https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1 with username=macster110, password=***
[INFO] Uploading to : https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.pom
[INFO] Uploading to : https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar
[INFO] Uploaded to : https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.pom (8.7 kB at 2.3 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.879 s
[INFO] Finished at: 2020-09-22T10:56:47+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project jtorch4pam: Failed to deploy artifacts: Could not transfer artifact org.jamdev:jtorch4pam:jar:0.0.63 from/to bintray-macster110-jtorch4pam (https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1): Access denied to https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar. Error code 401, 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 jtorch4pam: Failed to deploy artifacts: Could not transfer artifact org.jamdev:jtorch4pam:jar:0.0.63 from/to bintray-macster110-jtorch4pam (https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1): Access denied to https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar. Error code 401, Unauthorized
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact org.jamdev:jtorch4pam:jar:0.0.63 from/to bintray-macster110-jtorch4pam (https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1): Access denied to https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar. Error code 401, Unauthorized
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    ... 20 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact org.jamdev:jtorch4pam:jar:0.0.63 from/to bintray-macster110-jtorch4pam (https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1): Access denied to https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar. Error code 401, Unauthorized
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:146)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
    ... 22 more
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact org.jamdev:jtorch4pam:jar:0.0.63 from/to bintray-macster110-jtorch4pam (https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1): Access denied to https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar. Error code 401, Unauthorized
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:301)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:213)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:386)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:142)
    ... 24 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.jamdev:jtorch4pam:jar:0.0.63 from/to bintray-macster110-jtorch4pam (https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1): Access denied to https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar. Error code 401, Unauthorized
    at io.takari.aether.connector.AetherRepositoryConnector.wrap(AetherRepositoryConnector.java:889)
    at io.takari.aether.connector.AetherRepositoryConnector.wrap(AetherRepositoryConnector.java:1)
    at io.takari.aether.connector.AetherRepositoryConnector$PutTask.flush(AetherRepositoryConnector.java:732)
    at io.takari.aether.connector.AetherRepositoryConnector.put(AetherRepositoryConnector.java:373)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:295)
    ... 27 more
Caused by: io.takari.aether.connector.AuthorizationException: Access denied to https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1/org/jamdev/jtorch4pam/0.0.63/jtorch4pam-0.0.63.jar. Error code 401, Unauthorized
    at io.takari.aether.connector.AetherRepositoryConnector.handleResponseCode(AetherRepositoryConnector.java:397)
    at io.takari.aether.connector.AetherRepositoryConnector.access(AetherRepositoryConnector.java:391)
    at io.takari.aether.connector.AetherRepositoryConnector$PutTask.run(AetherRepositoryConnector.java:703)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:832)
[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

pom.xml 文件是

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.jamdev</groupId>
    <artifactId>jtorch4pam</artifactId>
    <version>0.0.63</version>
    <packaging>jar</packaging>


    <name>jamdev</name>
    <url>https://github.com/macster110/JTorch4PAM</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <id>spring-repo</id>
            <url>https://repo.spring.io/libs-milestone/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.facebook.soloader</groupId>
            <artifactId>nativeloader</artifactId>
            <version>0.9.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.facebook.fbjni/fbjni-java-only -->
        <dependency>
            <groupId>com.facebook.fbjni</groupId>
            <artifactId>fbjni-java-only</artifactId>
            <version>0.0.4</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.pytorch/pytorch_java_only -->
        <dependency>
            <groupId>org.pytorch</groupId>
            <artifactId>pytorch_java_only</artifactId>
            <version>1.6.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.jflac/jflac-codec -->
        <dependency>
            <groupId>org.jflac</groupId>
            <artifactId>jflac-codec</artifactId>
            <version>1.5.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-math3</artifactId>
            <version>3.6.1</version>
        </dependency>
        <!-- filter library -->
        <dependency>
            <groupId>uk.me.berndporr</groupId>
            <artifactId>iirj</artifactId>
            <version>1.1</version>
        </dependency>
        <!-- MATLAB import and export library -->
        <dependency>
            <groupId>us.hebi.matlab.mat</groupId>
            <artifactId>mfl-core</artifactId>
            <version>0.5.6</version>
        </dependency>
        <!-- Deep Java Library -->
        <dependency>
            <groupId>ai.djl</groupId>
            <artifactId>api</artifactId>
            <version>0.7.0</version>
        </dependency>

        <dependency>
            <groupId>ai.djl.pytorch</groupId>
            <artifactId>pytorch-model-zoo</artifactId>
            <version>0.7.0</version>
        </dependency>

        <dependency>
            <groupId>ai.djl.pytorch</groupId>
            <artifactId>pytorch-native-cpu</artifactId>
            <classifier>osx-x86_64</classifier>
            <version>1.6.0</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>ai.djl.pytorch</groupId>
            <artifactId>pytorch-native-auto</artifactId>
            <version>1.6.0</version>
            <scope>runtime</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>14</release>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.4.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
            </plugin>
        </plugins>
    </build>

    <licenses>
        <license>
            <name>GPL-3.0</name>
            <url>https://opensource.org/licenses/GPL-3.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <scm>
        <url>https://github.com/macster110/JTorch4PAM.git</url>
    </scm>
    <developers>
        <developer>
            <id>macster110</id>
            <name>Jamie Macaulay</name>
            <roles>
                <role>Developer</role>
            </roles>
        </developer>
    </developers>
    <description>Deep learning tools for passive acoustic monitoring</description>

    <distributionManagement>
        <repository>
            <id>bintray-macster110-jtorch4pam</id>
            <name>macster110-jtorch4pam</name>
            <url>https://api.bintray.com/maven/macster110/jtorch4pam/dl4pam/;publish=1</url>
        </repository>
    </distributionManagement>

</project>

settings.xml 文件(删除密码)

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
          xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
          <servers>
              <server>
                  <id>bintray-macster110-jtorch4pam</id>
                  <username>macster110</username>
                  <password>88888</password>
              </server>
          </servers>
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>bintray-macster110-jtorch4pam</id>
                    <name>bintray</name>
                    <url>https://dl.bintray.com/macster110/jtorch4pam</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>bintray-macster110-jtorch4pam</id>
                    <name>bintray-plugins</name>
                    <url>https://dl.bintray.com/macster110/jtorch4pam</url>
                </pluginRepository>
            </pluginRepositories>
            <id>bintray</id>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>bintray</activeProfile>
    </activeProfiles>
</settings>

我在eclipse中部署项目时使用的配置。

更新:解决方案

这个问题的解决方法是在外部安装maven并使用那个安装而不是Eclipse自带的嵌入式版本。这完全解决了问题。转到 preferences->Maven->Installation 以添加新的 Maven 安装,然后确保在 运行 配置中选择了该版本。

该错误表明存在基于 HTTP 401 代码消息的访问问题:

错误代码 401,未授权

仔细检查您的用户名和密码是否正确。

最好不要将密码放入明文,而是使用 password hash

尝试使用外部 Maven 安装。我认为 eclipse 中嵌入的 Maven(Maven 的 3.6.3 版本)在大文件方面存在问题(pom.xml 已正确部署)。

我们尝试使用 maven 3.5.1、3.6.1 和 3.6.3 外部安装并正确部署,但是给我们一个大文件(jar 或 war)和嵌入式文件(3.6.x)的 401 错误。 3).相同的配置和用户。

报告了一个与此相关的错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id=566513

报告了更多 Whosebug 问题:eclipse maven deploy war to nexus OSS Access denied Error code 401, Unauthorized


编辑:报告了一些关于错误的消息。好像和eclipse中加入okhttp组件有关,这个库有这个bug:

https://github.com/takari/aether-connector-okhttp/issues/29

在错误被修复之前提出了这 2 个解决方法:

  • 在启动配置中使用外部 Maven 运行时而不是嵌入式运行时(因此不包括 aether)
  • 在启动配置中设置 -Daether.connector.basic.threads=1

(您可以在 https://bugs.eclipse.org/bugs/show_bug.cgi?id=562847#c7 中看到)

此致,