Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

spring - SFTP Oubound Gateway Error - File List Command

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>
question from:https://stackoverflow.com/questions/65951035/sftp-oubound-gateway-error-file-list-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...