Maven deploy snapshot with scp throws NoSuchElementException

Simon Urli picture Simon Urli · Aug 3, 2017 · Viewed 14.4k times · Source

I want to be able to deploy a snapshot of a maven project on a nexus repository using scp. Here's the current configuration of my pom.xml for interesting parts:

<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>

The entire pom.xml is available there.

We are using pair of keys to authenticate to our repository, so I enter the following in ~/.m2/settings.xml:

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

And when I launch the mvn clean deploy I obtain the following error:

[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

Executing with debugging option show me the following 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)

For information, I'm using Maven 3.3.9, and Java 8 (I tested with openjdk and oracle JDK, with the same result).

I know my pom.xml setup should work: it worked for months on a virtual machine. Sadly I did not setup that VM and we lost it recently without any backup. I don't have any information on the java or maven version it was on this machine.

This VM was used through a jenkins Job to do mvn deploy periodically and you could have a look on the different logs of this job there: https://ci.inria.fr/sos/job/Spoon-Snapshot-Deployer/. Before July the 28th it worked well, the logs showing my error are since August the 2nd.

Answer

Aur&#233;lien Bourdon picture Aurélien Bourdon · Aug 3, 2017

Following your pom, error come from the wagon-ssh extension, used by the nexus-staging-maven-plugin.

As you don't know what could be versions used by your crashed VM, did you try by just updating the wagon-ssh version associated to the nexus-staging-maven-plugin? For example, by using:

 <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>