spring integration sftp mainframe :failed to write file; nested exception is 3: Permission denied

后端 未结 2 2126
青春惊慌失措
青春惊慌失措 2021-01-21 14:15

I am trying to sft file to mainframe using spring integration sftp:outbound-gateway: this is configuration:



        
2条回答
  •  半阙折子戏
    2021-01-21 15:05

    Why am I getting “Permission denied at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2297)”

    We received this error because on some sftp servers “/” meant the root of the user’s home directory, but on others it literally meant the server root to which the user obviously did not have permissions to write. We also received this on some sftp servers when the directory to which the user was trying to write didn’t exist.

    Another quete:

    I was having the problem also with SFTP and figured out that in the parameters for the File Writer FTP in the box to the right of the ftp server name or address you have to put the fully qualified path of the folder you are going to put files in. Otherwise the MIRTH SFTP tries to change directory to / and gets a permission denied. eg. sftp:// 111.222.333.444 / foldera/folderb/folderc/

    To find out what foldera/folderb/folderc/ should be use some sort of SFTP client that works (not MIRTH) and when it connects you it should show the path of folders that you are in.

    This worked for me.

    So, your issue that your SFTP path starts with /. The code from ChannelSftp.put:

    dst=remoteAbsolutePath(dst);
    ...
    private String remoteAbsolutePath(String path) throws SftpException{
       if(path.charAt(0)=='/') return path;
       String cwd=getCwd();
       if(cwd.endsWith("/")) return cwd+path;
       return cwd+"/"+path;
    }
    

    Try to figure out how to avoid / in the beginning.

提交回复
热议问题