问题描述
我正在尝试使用spring integration sftp将文件转发到大型机:outbound-gateway:
这是配置:
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"/>
其中
remote.upload.filename.credit.fmpl=/!DTS4.UP.G3TRF.S60304
remote.upload.directory=/
我得到的例外如下:
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)
如果我使用sftp客户端从命令行上传,则以下工作:
If I am uploading from command line using sftp client, the following works :
put filename //!DTS4.UP.G3TRF.S60304
但是通过spring集成,它不是。
服务器,我正在尝试sftp到:IBM z / OS大型机。
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.
谢谢你,
Anna
Thank you,Anna
推荐答案
我们收到此错误,因为在某些sftp上服务器/表示用户主目录的根目录,但在其他服务器上,它实际上是指用户显然没有写入权限的服务器根目录。当用户尝试写入的目录不存在时,我们也在某些sftp服务器上收到了这个。
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.
另一个问题:
要找出foldera / folderb / folderc /应该使用某种有效的SFTP客户端(不是MIRTH)当它连接你时它应该显示你所在的文件夹的路径。
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.
这对我有用。
因此,您的SFTP路径以 /
开头的问题。来自 ChannelSftp.put
的代码:
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.
这篇关于spring integration sftp mainframe:写文件失败;嵌套异常为3:权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!