Spring integration 使用出站网关删除文件失败

Spring integration 使用出站网关删除文件失败,spring-integration,jsch,Spring Integration,Jsch,我正在尝试使用sftp出站网关删除远程sftp上的特定日志文件 <int-sftp:outbound-gateway id="removeSourceGateway" session-factory="sftpCachingSessionFactory" reply-channel="outputChannel"

我正在尝试使用sftp出站网关删除远程sftp上的特定日志文件

<int-sftp:outbound-gateway id="removeSourceGateway"
                               session-factory="sftpCachingSessionFactory" 
                               reply-channel="outputChannel"
                               request-channel="afterSuccessBackupChannel"
                               requires-reply="false"
                               command="ls"
                               expression="'/export/logs/'"
                               remote-directory="${sftp.remote.dir}">
</int-sftp:outbound-gateway>
为了使这个问题更加复杂,每当我使用WinSCP连接到SFTP并使用完全相同的帐户时,我就能够完全删除远程文件

错误消息:

2015-06-17 15:19:56 INFO  jsch:52 - SSH_MSG_NEWKEYS received
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 INFO  jsch:52 - SSH_MSG_SERVICE_REQUEST sent
2015-06-17 15:19:56 INFO  jsch:52 - SSH_MSG_SERVICE_REQUEST sent
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 INFO  jsch:52 - SSH_MSG_SERVICE_ACCEPT received
2015-06-17 15:19:56 INFO  jsch:52 - SSH_MSG_SERVICE_ACCEPT received
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 INFO  jsch:52 - Authentications that can continue: password
2015-06-17 15:19:56 INFO  jsch:52 - Authentications that can continue: password
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 INFO  jsch:52 - Next authentication method: password
2015-06-17 15:19:56 INFO  jsch:52 - Next authentication method: password
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 INFO  jsch:52 - Authentication succeeded (password).
2015-06-17 15:19:56 INFO  jsch:52 - Authentication succeeded (password).
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 DEBUG SimplePool:190 - Obtained new org.springframework.integration.sftp.session.SftpSession@3b63f280.
2015-06-17 15:19:56 DEBUG SimplePool:190 - Obtained new org.springframework.integration.sftp.session.SftpSession@3b63f280.
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 INFO  jsch:52 - Disconnecting from *.*.*.* port 22
2015-06-17 15:19:56 INFO  jsch:52 - Disconnecting from *.*.*.* port 22
2015-06-17 15:19:56 INFO  stdout:71 - 2015-06-17 15:19:56 DEBUG SimplePool:221 - Releasing org.springframework.integration.sftp.session.SftpSession@3b63f280 back to the pool
2015-06-17 15:19:56 DEBUG SimplePool:221 - Releasing org.springframework.integration.sftp.session.SftpSession@3b63f280 back to the pool
2015-06-17 15:19:57 INFO  stdout:71 - 2015-06-17 15:19:57 DEBUG DefaultListableBeanFactory:248 - Returning cached instance of singleton bean 'integrationEvaluationContext'
2015-06-17 15:19:57 DEBUG DefaultListableBeanFactory:248 - Returning cached instance of singleton bean 'integrationEvaluationContext'
2015-06-17 15:19:57 INFO  stdout:71 - 2015-06-17 15:19:57 DEBUG DirectChannel:277 - preSend on channel 'outputChannel', message: ErrorMessage [payload=org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice$MessageHandlingExpressionEvaluatingAdviceException: Handler Failed; nested exception is org.springframework.messaging.MessagingException: ; nested exception is org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is org.springframework.core.NestedIOException: Failed to remove file: 4: Failure, headers={timestamp=1434547197002, id=18ca7961-f5f0-de0d-03f2-04909dbcdebc}]
2015-06-17 15:19:57 DEBUG DirectChannel:277 - preSend on channel 'outputChannel', message: ErrorMessage [payload=org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice$MessageHandlingExpressionEvaluatingAdviceException: Handler Failed; nested exception is org.springframework.messaging.MessagingException: ; nested exception is org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is org.springframework.core.NestedIOException: Failed to remove file: 4: Failure, headers={timestamp=1434547197002, id=18ca7961-f5f0-de0d-03f2-04909dbcdebc}]
2015-06-17 15:19:57 INFO  stdout:71 - 2015-06-17 15:19:57 DEBUG CharacterStreamWritingMessageHandler:72 - org.springframework.integration.stream.CharacterStreamWritingMessageHandler#0 received message: ErrorMessage [payload=org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice$MessageHandlingExpressionEvaluatingAdviceException: Handler Failed; nested exception is org.springframework.messaging.MessagingException: ; nested exception is org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is org.springframework.core.NestedIOException: Failed to remove file: 4: Failure, headers={timestamp=1434547197002, id=18ca7961-f5f0-de0d-03f2-04909dbcdebc}]
2015-06-17 15:19:57 DEBUG CharacterStreamWritingMessageHandler:72 - org.springframework.integration.stream.CharacterStreamWritingMessageHandler#0 received message: ErrorMessage [payload=org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice$MessageHandlingExpressionEvaluatingAdviceException: Handler Failed; nested exception is org.springframework.messaging.MessagingException: ; nested exception is org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is org.springframework.core.NestedIOException: Failed to remove file: 4: Failure, headers={timestamp=1434547197002, id=18ca7961-f5f0-de0d-03f2-04909dbcdebc}]
2015-06-17 15:19:57 INFO  stdout:71 - org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice$MessageHandlingExpressionEvaluatingAdviceException: Handler Failed; nested exception is org.springframework.messaging.MessagingException: ; nested exception is org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is org.springframework.core.NestedIOException: Failed to remove file: 4: Failure
2015-06-17 15:19:57 INFO  stdout:71 -   at org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice.evaluateFailureExpression(ExpressionEvaluatingRequestHandlerAdvice.java:185)
2015-06-17 15:19:57 INFO  stdout:71 -   at org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice.doInvoke(ExpressionEvaluatingRequestHandlerAdvice.java:143)
2015-06-17 15:19:57 INFO  stdout:71 -   at org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice.invoke(AbstractRequestHandlerAdvice.java:69)
2015-06-17 15:19:57 INFO  stdout:71 -   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
2015-06-17 15:19:57 INFO  stdout:71 -   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
2015-06-17 15:19:57 INFO  stdout:71 -   at com.sun.proxy.$Proxy62.handleMessage(Unknown Source)
为确保完整性,我将向我的出站网关发送以下内容:

2015-06-17 15:38:15 INFO  FtpSession:126 - File has been successfully transfered to: /Private/logs/2015-06/sdk.20150601003030.log
2015-06-17 15:38:15 INFO  stdout:71 - 2015-06-17 15:38:15 DEBUG SimplePool:221 - Releasing org.springframework.integration.ftp.session.FtpSession@2718fca1 back to the pool
2015-06-17 15:38:15 DEBUG SimplePool:221 - Releasing org.springframework.integration.ftp.session.FtpSession@2718fca1 back to the pool
2015-06-17 15:38:15 INFO  stdout:71 - 2015-06-17 15:38:15 DEBUG DefaultListableBeanFactory:248 - Returning cached instance of singleton bean 'integrationEvaluationContext'
2015-06-17 15:38:15 DEBUG DefaultListableBeanFactory:248 - Returning cached instance of singleton bean 'integrationEvaluationContext'
2015-06-17 15:38:15 INFO  stdout:71 - 2015-06-17 15:38:15 DEBUG DirectChannel:277 - preSend on channel 'afterSuccessBackupChannel', message: AdviceMessage [payload=/data/logs/live-test/sdk/sdk.20150601003030.log, headers={timestamp=1434548295753, id=17408be9-8acd-0325-b726-e87c81cafcc8}]
2015-06-17 15:38:15 DEBUG DirectChannel:277 - preSend on channel 'afterSuccessBackupChannel', message: AdviceMessage [payload=/data/logs/live-test/sdk/sdk.20150601003030.log, headers={timestamp=1434548295753, id=17408be9-8acd-0325-b726-e87c81cafcc8}]
2015-06-17 15:38:15 INFO  stdout:71 - 2015-06-17 15:38:15 DEBUG SftpOutboundGateway:72 - org.springframework.integration.sftp.gateway.SftpOutboundGateway#0 received message: AdviceMessage [payload=/data/logs/live-test/sdk/sdk.20150601003030.log, headers={timestamp=1434548295753, id=17408be9-8acd-0325-b726-e87c81cafcc8}]
2015-06-17 15:38:15 DEBUG SftpOutboundGateway:72 - org.springframework.integration.sftp.gateway.SftpOutboundGateway#0 received message: AdviceMessage [payload=/data/logs/live-test/sdk/sdk.20150601003030.log, headers={timestamp=1434548295753, id=17408be9-8acd-0325-b726-e87c81cafcc8}]
2015-06-17 15:38:15 INFO  stdout:71 - 2015-06-17 15:38:15 DEBUG DefaultListableBeanFactory:248 - Returning cached instance of singleton bean 'integrationEvaluationContext'
2015-06-17 15:38:15 DEBUG DefaultListableBeanFactory:248 - Returning cached instance of singleton bean 'integrationEvaluationContext'
2015-06-17 15:38:15 INFO  stdout:71 - 2015-06-17 15:38:15 INFO  jsch:52 - Connecting to *.*.*.* port 22
干杯,杰斯

未能删除文件:4:失败

不幸的是,在本例中,
com.jcraft.jsch
库(用于sftp)中的异常有点神秘(
4:Failure

4表示:

SSH_FX_FAILURE
  is a generic catch-all error message; it should be returned if an
  error occurs for which there is no more specific error code
  defined.
…深入研究jsch代码,我觉得这个状态是由服务器返回的。服务器日志中有什么内容吗

如果没有,您可能必须使用wireshark或类似工具来找出服务器不喜欢rm请求的地方

SSH_FX_FAILURE
  is a generic catch-all error message; it should be returned if an
  error occurs for which there is no more specific error code
  defined.