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