Maven Wagon
  1. Maven Wagon
  2. WAGON-354

Site deployment always fails with StringIndexOutOfBoundsException in SftpWagon

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.0, 2.0
    • Fix Version/s: backlog
    • Component/s: wagon-ssh
    • Labels:
      None
    • Environment:
      Maven 3.0.3, Site-Plugin 3.0, Wagon 2.0
    • Number of attachments :
      1

      Description

      I always get StringIndexOutOfBoundsException on the attempt to deploy a site with SFTP using Maven 3 + Site Plugin 3.

      Calling "mvn site-deploy" causes:

      ...
      Caused by: org.apache.maven.plugin.MojoExecutionException: Error uploading site
              at org.apache.maven.plugins.site.AbstractDeployMojo.push(AbstractDeployMojo.java:464)
              at org.apache.maven.plugins.site.AbstractDeployMojo.deploy(AbstractDeployMojo.java:296)
              at org.apache.maven.plugins.site.AbstractDeployMojo.deployTo(AbstractDeployMojo.java:257)
              at org.apache.maven.plugins.site.AbstractDeployMojo.execute(AbstractDeployMojo.java:165)
              at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
              ... 19 more
      Caused by: org.apache.maven.wagon.TransferFailedException: Error occurred while deploying 'c:\Projects\OS\doxia-include\target\site' to remo
      te repository: sftp://web.sourceforge.net/home/groups/d/do/doxia-include/htdocs/:
              at org.apache.maven.wagon.providers.ssh.jsch.SftpWagon.putDirectory(SftpWagon.java:286)
              at org.apache.maven.plugins.site.AbstractDeployMojo.push(AbstractDeployMojo.java:447)
              ... 24 more
      Caused by: 4:
              at com.jcraft.jsch.ChannelSftp.mkdir(ChannelSftp.java:1713)
              at org.apache.maven.wagon.providers.ssh.jsch.SftpWagon.mkdir(SftpWagon.java:204)
              at org.apache.maven.wagon.providers.ssh.jsch.SftpWagon.ftpRecursivePut(SftpWagon.java:300)
              at org.apache.maven.wagon.providers.ssh.jsch.SftpWagon.putDirectory(SftpWagon.java:277)
              ... 25 more
      Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
              at java.lang.String.charAt(String.java:686)
              at com.jcraft.jsch.ChannelSftp.remoteAbsolutePath(ChannelSftp.java:2367)
              at com.jcraft.jsch.ChannelSftp.mkdir(ChannelSftp.java:1691)
              ... 28 more
      

      The configuration is:

       
      <properties>
        <application.id>doxia-include</application.id>
      </properties>
      <distributionManagement>
        <site>
          <id>${application.id}.shell.sourceforge.net</id>
          <name>${application.id}.shell.sourceforge.net</name>
          <url>sftp://web.sourceforge.net/home/groups/d/do/${application.id}/htdocs</url>
        </site>
      

      (Btw. I tried variuous urls, "../htdocs", "../htdocs/" and "../htdocs/." but the site plugin always normalizes them to "../htdocs/", which is actually the right thing to do.)

      My assumption why it happens:

      I looked at the sources of wagon (particularly to the methods mentioned in the stack trace), and I think the issue seems to be that:

      • Site Plugin 3 always normalizes the remote directory to end with a trailing slash.
      • WagonSftp.putDirectory:277 calls ScpHelper.getResourceFilename( destinationDirectory ) on this directory which returns an empty string.
      • WagonSfto.ftpRecursivePut:300 calls mkdir with an empty string which causes the exception.

      Actually it looks as if older site plugins added a trailing "/." to the path instead of just "/" as otherwise it would have been broken before (I did not verify this). Nevertheless I think the bug is in the Wagon implementation as it should not fail if the destination is given like this.

        Issue Links

          Activity

          Olivier Lamy made changes -
          Field Original Value New Value
          Fix Version/s 2.1 [ 17844 ]
          Olivier Lamy made changes -
          Fix Version/s 2.2 [ 18090 ]
          Fix Version/s 2.1 [ 17844 ]
          Hide
          Nicolas Richeton added a comment -

          I face the same issue. This totally prevents site deployment

          Show
          Nicolas Richeton added a comment - I face the same issue. This totally prevents site deployment
          Olivier Lamy made changes -
          Fix Version/s 2.3 [ 18140 ]
          Fix Version/s 2.2 [ 18090 ]
          Hide
          Archimedes Trajano added a comment -

          Is there a workaround?

          Show
          Archimedes Trajano added a comment - Is there a workaround?
          Jason van Zyl made changes -
          Fix Version/s backlog [ 17841 ]
          Fix Version/s 2.3 [ 18140 ]
          Hide
          Jackie Noi added a comment -

          This problem starts as of version 2.3 of maven-site-plugin - also in Maven 2. A temporary workaround is to downgrade to 2.2.

          Show
          Jackie Noi added a comment - This problem starts as of version 2.3 of maven-site-plugin - also in Maven 2. A temporary workaround is to downgrade to 2.2.
          Jackie Noi made changes -
          Link This issue relates to MSITE-681 [ MSITE-681 ]
          Hide
          Archimedes Trajano added a comment -

          Is there a workaround for Maven 3?

          Show
          Archimedes Trajano added a comment - Is there a workaround for Maven 3?
          Hide
          Michael Koch added a comment -

          I agree with Juergens analysis and conclusion that SftpWagon.putDirectory should not fail if the destinationDirectory ends with a "/". I've attached a patch which changes ScpHelper.getResourceFilename to return a "." instead of "" if the resource path ends with a "/". This fixes the site deployment for me.

          Show
          Michael Koch added a comment - I agree with Juergens analysis and conclusion that SftpWagon.putDirectory should not fail if the destinationDirectory ends with a "/" . I've attached a patch which changes ScpHelper.getResourceFilename to return a "." instead of "" if the resource path ends with a "/" . This fixes the site deployment for me.
          Michael Koch made changes -
          Hide
          Nicolas Richeton added a comment -

          This is a critical issue opened for more than 20 months with no workaround for Maven3 (other than 'don't use sftp'). A patch has been available for 4 months. Is there any issue with the attached patch ? Is there anything we can do to help to get this committed and to have the patched wagon-ssh released ?

          Show
          Nicolas Richeton added a comment - This is a critical issue opened for more than 20 months with no workaround for Maven3 (other than 'don't use sftp'). A patch has been available for 4 months. Is there any issue with the attached patch ? Is there anything we can do to help to get this committed and to have the patched wagon-ssh released ?
          Hide
          Drew MacInnis added a comment - - edited

          I was able to perform site-deploy via sftp for my project using these plugin settings:

              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-site-plugin</artifactId>
                  <version>3.3</version>
                  <configuration>
                      <chmod>false</chmod>
                  </configuration>
                  <dependencies>
                      <dependency>
                          <groupId>org.apache.maven.wagon</groupId>
                          <artifactId>wagon-ssh</artifactId>
                          <version>2.5</version>
                      </dependency>
                  </dependencies>
              </plugin>
          
          Show
          Drew MacInnis added a comment - - edited I was able to perform site-deploy via sftp for my project using these plugin settings: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>3.3</version> <configuration> <chmod>false</chmod> </configuration> <dependencies> <dependency> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ssh</artifactId> <version>2.5</version> </dependency> </dependencies> </plugin>

            People

            • Assignee:
              Unassigned
              Reporter:
              Juergen Kellerer
            • Votes:
              9 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated: