Reputation: 69
I have a sftp server with this directory structure :
main
--directoryA
--subDirectory1
--directoryB
--subDirectory1
But when I tried to get the directory list using sftp outbound gateway, I am getting this error :
Caused by: com.jcraft.jsch.SftpException: main/directoryA/directoryA/subDirectory1
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2225) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2242) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1592) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1553) ~[jsch-0.1.55.jar:na]
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:111) ~[spring-integration-sftp-5.3.3.RELEASE.jar:5.3.3.RELEASE]
... 47 common frames omitted
I'm not sure why the directoryA is appending twice. Here is my outbound gateway :
<int-sftp:outbound-gateway id="gateway"
expression="payload"
request-channel="request"
remote-directory="main"
command-options="-dirs -R"
command="ls"
session-factory="sessionFactory"
reply-channel="reply">
</int-sftp:outbound-gateway>
Upvotes: 0
Views: 270
Reputation: 174769
Look on the server logs to see if there are any clues there.
Maybe you don't have permissions to access that subdir?
if(type!=SSH_FXP_ATTRS){
if(type==SSH_FXP_STATUS){
int i=buf.getInt();
throwStatusError(buf, i);
}
According to the stack trace, the server returned 101 (the client is expecting 105).
The value (i) does not appear in the SftpException.getMessage()
shown in the stack trace.
You can see it by traversing the cause()
chain and using toString()
.
public class SftpException extends Exception{
//private static final long serialVersionUID=-5616888495583253811L;
public int id;
private Throwable cause=null;
public SftpException (int id, String message) {
super(message);
this.id=id;
}
public SftpException (int id, String message, Throwable e) {
super(message);
this.id=id;
this.cause=e;
}
public String toString(){
return id+": "+getMessage();
}
public Throwable getCause(){
return this.cause;
}
}
It might provide more clues.
Upvotes: 1