【问题标题】:Logging the actual file/directory on SFTP "no such file" failure在 SFTP“无此类文件”失败时记录实际文件/目录
【发布时间】:2018-09-28 23:22:53
【问题描述】:

我们大量使用 Spring Integration,它运行良好。但是,我不确定如何让 Jsch/Spring Integration 记录有问题的实际文件,当我收到一个错误时,例如,尝试在 sftp 服务器上不存在的目录上执行列表.我得到如下异常。

有什么方法可以诱使 Spring Integration 或 Jsch 打印出“没有此类文件”的文件信息?当我查看 Jsch 代码时,似乎没有针对该特定问题的任何日志记录,但我可能遗漏了某些内容,即使它没有某些内容,也可能捕获此异常的 Spring 代码具有一些上下文可以登录。

事实上,我们要么必须在这样的实例中附加调试器,要么尝试对我们可能需要设置的一个或多个目录做出有根据的猜测。

Caused by: org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is org.springframework.core.NestedIOException: Failed to list files; nested exception is 2: No such file
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:444)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:235)
    ... 13 common frames omitted
Caused by: org.springframework.core.NestedIOException: Failed to list files; nested exception is 2: No such file
    at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:104)
    at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:50)
    at org.springframework.integration.file.remote.session.CachingSessionFactory$CachedSession.list(CachingSessionFactory.java:218)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:239)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:235)
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:435)
    ... 14 common frames omitted
Caused by: com.jcraft.jsch.SftpException: No such file
    at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873)

【问题讨论】:

  • 为什么不在消息头中设置文件名并将其记录在异常处理程序中?
  • 不错的主意,但我不确定我是否能在所有情况下都找到明确的方法。例如,我们使用 int-sftp:inbound-channel-adapter,并在看到文件时将其馈入通道。有没有办法将远程目录值添加到标题中?

标签: spring-integration spring-integration-sftp


【解决方案1】:

我打开INT-4534将目录添加到异常中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-01
    • 2020-08-07
    • 2021-12-26
    • 2013-03-29
    • 1970-01-01
    • 2018-05-28
    相关资源
    最近更新 更多