使用scp的Maven部署快照会抛出NoSuchElementException

时间:2017-08-03 12:05:52

标签: java maven snapshot wagon

我希望能够使用scp在nexus存储库上部署maven项目的快照。 这是我的pom.xml的当前配置,用于有趣的部分:

<distributionManagement>
    <snapshotRepository>
      <id>gforge.inria.fr-snapshot</id>
      <name>inria-snapshots</name>
      <url>scp://scm.gforge.inria.fr/home/groups/spoon/htdocs/repositories/snapshots</url>
    </snapshotRepository>
    <site>
      <id>gforge.inria.fr-site</id>
      <name>inria</name>
      <url>scp://scm.gforge.inria.fr/home/groups/spoon/htdocs/mvnsites/spoon-core</url>
    </site>
  </distributionManagement>
  [...]
<extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-ssh</artifactId>
      </extension>
    </extensions>
  </build>

整个pom.xml可用there

我们使用一对密钥对我们的存储库进行身份验证,因此我在~/.m2/settings.xml中输入以下内容:

<server>
  <id>gforge.inria.fr-snapshot</id>
  <username>XXXX</username>
  <privateKey>/path/to/the/private/key</privateKey>
</server>

当我启动mvn clean deploy时,我收到以下错误:

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.2:deploy (injected-nexus-deploy) on project spoon-core: Failed to deploy artifacts/metadata: Cannot access scp://scm.gforge.inria.fr/home/groups/spoon/htdocs/repositories/snapshots with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access scp://scm.gforge.inria.fr/home/groups/spoon/htdocs/repositories/snapshots using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
[ERROR] role: org.apache.maven.wagon.Wagon
[ERROR] roleHint: scp

使用调试选项执行显示以下stacktrace:

java.util.NoSuchElementException
      role: org.apache.maven.wagon.Wagon
  roleHint: scp
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
      role: org.apache.maven.wagon.Wagon
  roleHint: scp
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
    at org.eclipse.aether.internal.transport.wagon.PlexusWagonProvider.lookup(PlexusWagonProvider.java:58)
    at org.eclipse.aether.transport.wagon.WagonTransporter.lookupWagon(WagonTransporter.java:271)
    at org.eclipse.aether.transport.wagon.WagonTransporter.<init>(WagonTransporter.java:115)
    at org.eclipse.aether.transport.wagon.WagonTransporterFactory.newInstance(WagonTransporterFactory.java:127)
    at org.eclipse.aether.internal.impl.DefaultTransporterProvider.newTransporter(DefaultTransporterProvider.java:110)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector.<init>(BasicRepositoryConnector.java:115)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory.newInstance(BasicRepositoryConnectorFactory.java:180)
    at org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider.newRepositoryConnector(DefaultRepositoryConnectorProvider.java:113)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:265)

有关信息,我使用的是Maven 3.3.9和Java 8(我使用openjdk和oracle JDK进行了测试,结果相同)。

我知道我的pom.xml设置应该可行:它在虚拟机上工作了好几个月。可悲的是,我没有设置该VM,我们最近没有任何备份而丢失了它。我没有关于这台机器上的java或maven版本的任何信息。

此VM通过jenkins Job定期执行mvn deploy,您可以查看此作业的不同日志:https://ci.inria.fr/sos/job/Spoon-Snapshot-Deployer/。在7月28日之前它运行良好,显示我的错误的日志是从8月2日开始。

1 个答案:

答案 0 :(得分:1)

关注您的pom后,错误来自wagon-ssh使用的nexus-staging-maven-plugin扩展程序。

由于您不知道崩溃的VM使用的版本是什么,您是否尝试更新与wagon-ssh关联的nexus-staging-maven-plugin版本?例如,通过使用:

 <plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.6.2</version>
    <extensions>true</extensions>
    <configuration>
      <serverId>ossrh</serverId>
      <nexusUrl>https://oss.sonatype.org/</nexusUrl>
      <autoReleaseAfterClose>true</autoReleaseAfterClose>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ssh</artifactId>
        <version>2.12</version>
      </dependency>
    </dependencies>
  </plugin>