2015-06-17 4 views
1

Я пытаюсь использовать исходящий шлюз 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> 

Если я исполняю LS или PUT команды в описанной выше конфигурации, то я получаю ожидаемый контент - см ниже пример сообщения LS. Но всякий раз, когда я пытаюсь запустить команду RM, я получаю довольно загадочное сообщение об ошибке.

GenericMessage [payload=[FileInfo [isDirectory=false, isLink=false, Size=2348, ModifiedTime=Wed Jun 17 15:21:13 CEST 2015, Filename=sdk.20150601003030.log, RemoteDirectory=/export/logs/, Permissions=-rw-rw-rw-]] 

Чтобы добавить таинственности к этой проблеме, когда я подключиться к SFTP с помощью WinSCP и используя тот же счет, я тогда pefectly возможность удалить удаленный файл!

Сообщение об ошибке:

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 [email protected]0. 
2015-06-17 15:19:56 DEBUG SimplePool:190 - Obtained new [email protected]0. 
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 [email protected]0 back to the pool 
2015-06-17 15:19:56 DEBUG SimplePool:221 - Releasing [email protected]0 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 [email protected] back to the pool 
2015-06-17 15:38:15 DEBUG SimplePool:221 - Releasing [email protected] 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 

Приветствия, Jes

ответ

1

Не удалось удалить файл: 4: Отказ

К сожалению, исключение из com.jcraft.jsch библиотеки (используемое для SFTP) немного загадочных (4: Failure) в этом случае ...

-средств:

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, мне кажется, что этот статус был возвращен сервером. Есть ли что-либо в журналах сервера?

Если нет, возможно, вам придется использовать wirehark или аналогичный, чтобы выяснить, что серверу не нравится в запросе rm.

Смежные вопросы