Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-665

Apache VFS FileObject copyFrom() Exception

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Labels:

      Description

       
      I am using the below class to transfer a file from one folder to another on a server I am using commons-vfs-2.0 jar. :

      import org.apache.commons.vfs.FileObject;

      import org.apache.commons.vfs.FileSystemException;

      import org.apache.commons.vfs.FileSystemOptions;

      import org.apache.commons.vfs.Selectors;

      import org.apache.commons.vfs.impl.StandardFileSystemManager;

      import org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder;

      public class SFTPTest {

      public static void main(String args[]) {

      try

      { String ftpUrlSrc = "sftp.host.address" + ":" + "8022" + "/SRC_FOLDER"; String sftpUriSrc = "sftp://" + "sftpUser" + ":" + "pass$123" + "@" + ftpUrlSrc; String ftpUrlDest = "sftp.host.address" + ":" + "8022" + "/DEST_FOLDER"; String sftpUriDest = "sftp://" + "sftpUser" + ":" + "pass$123" + "@" + ftpUrlDest; StandardFileSystemManager manager = new StandardFileSystemManager(); FileSystemOptions opts = new FileSystemOptions(); SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no"); manager.init(); FileObject fileObjectSrc = manager.resolveFile(sftpUriSrc + "/" + "trial_file.tar.gz", opts); FileObject fileObjectDest = manager.resolveFile(sftpUriDest + "/" + "trial_file.tar.gz", opts); fileObjectDest.copyFrom(fileObjectSrc, Selectors.SELECT_SELF); //The below moveTo() call works without any issue. fileObjectSrc.moveTo(fileObjectDest); }

      catch (FileSystemException e)

      { // TODO Auto-generated catch block e.printStackTrace(); }

      }

      }

      The below exception is being thrown:

       org.apache.commons.vfs.FileSystemException: Could not copy "sftp://sftpUser:**@sftp.host.address:8022/SRC_FOLDER/trial_file.tar.gz" to "sftp://sftpUser:*@sftp.host.address:8022/DEST_FOLDER/trial_file.tar.gz". at org.apache.commons.vfs.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:1032) at SFTPTest.main(SFTPTest.java:27)

      Caused by: org.apache.commons.vfs.FileSystemException: Could not close the output stream for file "sftp://sftpUser:**@sftp.host.address:8022/DEST_FOLDER/trial_file.tar.gz". at org.apache.commons.vfs.provider.DefaultFileContent$FileContentOutputStream.close(DefaultFileContent.java:686) at org.apache.commons.vfs.FileUtil.copyContent(FileUtil.java:119) at org.apache.commons.vfs.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:1023) ... 1 more

      Caused by: java.io.IOException: 4: Transfer failed possibly due to access restrictions. at com.jcraft.jsch.ChannelSftp$1.flush(ChannelSftp.java:858) at com.jcraft.jsch.ChannelSftp$1.close(ChannelSftp.java:867) at java.io.FilterOutputStream.close(FilterOutputStream.java:160) at org.apache.commons.vfs.util.MonitorOutputStream.close(MonitorOutputStream.java:56) at java.io.FilterOutputStream.close(FilterOutputStream.java:160) at org.apache.commons.vfs.util.MonitorOutputStream.close(MonitorOutputStream.java:56) at org.apache.commons.vfs.provider.DefaultFileContent$FileContentOutputStream.close(DefaultFileContent.java:682) ... 3 more}}{{}}

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              norva Yogesh Kumar
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: