Spring Batch问题:"将远程同步到本地目录时出现问题"

时间:2016-06-02 12:21:06

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

我们将PUT文件放在某个SFTP服务器上,然后运行spring批处理。当执行下面的Spring批处理运行时。

  1. 从FTP位置选择文件

  2. 处理文件。

  3. 删除文件。

  4. 我们面临异常,而春季批次执行上述步骤。

    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
    

1 个答案:

答案 0 :(得分:1)

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

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

您应该查阅服务器日志。