java - Spring 批处理问题 : "Problems occurred while synchronizing remote to local directory"

标签 java spring spring-integration spring-batch spring-integration-sftp

我们将文件放在某个 SFTP 服务器上,然后运行 ​​spring Batch。当 Spring Batch 运行时,执行以下步骤。

  1. 从 FTP 位置选择文件

  2. 处理文件。

  3. 删除文件。

当 Spring Batch 执行上述步骤时,我们面临以下异常。

ERROR org.springframework.integration.handler.LoggingHandler: 140 - org.springframework.integration.MessagingException: Problem occurred while synchronizing remote to local directory
            at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:189)
            at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.receive(AbstractInboundFileSynchronizingMessageSource.java:162)
            at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:111)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:184)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:51)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:143)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:141)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:273)
            at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
            at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
            at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:268)
            at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
            at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:662)
        Caused by: org.springframework.integration.MessagingException: Failed to execute on session
            at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:306)
            at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:163)
            ... 21 more
        Caused by: org.springframework.core.NestedIOException: Failed to remove file: 2: Specified file path is invalid.
            at org.springframework.integration.sftp.session.SftpSession.remove(SftpSession.java:83)
            at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.copyFileToLocalDirectory(AbstractInboundFileSynchronizer.java:230)
            at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.access$100(AbstractInboundFileSynchronizer.java:59)
            at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:172)
            at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:163)
            at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:297)
            ... 22 more

最佳答案

可能是安全问题 - 也许您没有删除权限。

获取和删除时使用完全相同的路径(如果配置为在检索后删除远程文件)。显然,提取工作正常,因为我们现在处于删除阶段。

您应该查阅服务器日志。

关于java - Spring 批处理问题 : "Problems occurred while synchronizing remote to local directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37591733/

相关文章:

java - Spring 集成使用 1 个 channel 用于两个不同的进程

java - 关于字符串操作的问题

java - 如何在Java中定义自定义异常类,最简单的方法?

java - Spring Boot 请求映射根路径 Controller 仅使用双斜杠

java - Spring 数据 JPA : Fetching data from entity just after save() method

java - Thymeleaf HTML 页面转发问题到 Spring Boot App 中的外部网站

java - Web服务上下文: Is it there a way to inject it any where appart from my WebService?

java - 无法在 openshift 上打开传出连接(套接字)

java - Spring集成文件 - 在写入文件之前通过入站 channel 适配器读取文件

java - admob 测试广告出现