I am trying to sft file to mainframe using spring integration sftp:outbound-gateway: this is configuration:
<sftp:outbound-gateway id="putGateway"
session-factory="sftpSessionFactory"
request-channel="sftpFileInputChannel"
command="put"
expression="payload"
remote-directory="${remote.upload.directory}"
remote-filename-generator-expression="'${remote.upload.filename}'"
use-temporary-file-name="false"
reply-channel="replayFromPutSftpChannel"/>
where
remote.upload.filename.credit.fmpl=/!DTS4.UP.G3TRF.S60304
remote.upload.directory=/
I am getting exception like :
Caused by: org.springframework.integration.MessagingException: Failed to write to '//!DTS4.UP.G3TRF.S60304' while uploading the file
at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:392)
at org.springframework.integration.file.remote.RemoteFileTemplate.access$500(RemoteFileTemplate.java:56)
at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:213)
... 46 more
Caused by: org.springframework.core.NestedIOException: failed to write file; nested exception is 3: Permission denied
at org.springframework.integration.sftp.session.SftpSession.write(SftpSession.java:158)
at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:385)
... 48 more
Caused by: 3: Permission denied
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2629)
at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:545)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:491)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:454)
at org.springframework.integration.sftp.session.SftpSession.write(SftpSession.java:155)
If I am uploading from command line using sftp client, the following works :
put filename //!DTS4.UP.G3TRF.S60304
but via spring integration , it does not. The server, I am trying to sftp to is : IBM z/OS mainframe .
Please help if you know how to resolve the issue.
Thank you, Anna
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.
来源:https://stackoverflow.com/questions/25877027/spring-integration-sftp-mainframe-failed-to-write-file-nested-exception-is-3