Java org.springframework.MessagingException:将远程目录同步到本地目录时出现问题

Java org.springframework.MessagingException:将远程目录同步到本地目录时出现问题,java,spring-boot,spring-batch,jsch,Java,Spring Boot,Spring Batch,Jsch,我有一个spring批处理应用程序,其中批处理连续运行,通过SFTP从另一台服务器提取数据。在日志中,我不断地看到下面提到的错误,但看起来批处理正在按预期工作,它从另一台服务器提取文件时没有任何问题。我不知道为什么它在日志中抛出错误。奇怪的是,同样的代码并没有在qa-env中抛出任何错误,而是在prod中抛出的唯一错误。 批处理正在执行其工作,但其抛出错误也在日志中 有谁能给我建议如何消除这个错误吗 下面是创建sessionfactory的代码 **public SessionFactory&l

我有一个spring批处理应用程序,其中批处理连续运行,通过SFTP从另一台服务器提取数据。在日志中,我不断地看到下面提到的错误,但看起来批处理正在按预期工作,它从另一台服务器提取文件时没有任何问题。我不知道为什么它在日志中抛出错误。奇怪的是,同样的代码并没有在qa-env中抛出任何错误,而是在prod中抛出的唯一错误。 批处理正在执行其工作,但其抛出错误也在日志中

有谁能给我建议如何消除这个错误吗

下面是创建sessionfactory的代码

**public SessionFactory<LsEntry> pimSftpSessionFactory() {
        Resource resource = new FileSystemResource(
                sftpProperties.privateKeyLocation);
        Properties config = new Properties();
        config.put("PreferredAuthentications", "publickey,password");
        DefaultSftpSessionFactory sftpSessionFactory = new DefaultSftpSessionFactory();
        sftpSessionFactory.setHost(sftpProperties.hostName);
        sftpSessionFactory.setPort(sftpProperties.port);
        sftpSessionFactory.setUser(sftpProperties.username);
        sftpSessionFactory.setKnownHosts(sftpProperties.knownHosts);
        sftpSessionFactory.setPrivateKey(resource);
        sftpSessionFactory.setSessionConfig(config);
        return sftpSessionFactory;** 

中间有防火墙吗?这很可能是网络问题。当我使用sftp命令连接到目标linux服务器时,从源linux服务器连接到目标linux服务器。其间有防火墙吗?这很可能是网络问题。当我使用sftp命令连接到目标linux服务器时,从源linux服务器开始连接。
 **<dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-sftp</artifactId>
    </dependency>**
        
03 Sep 2020 01:47:56.688 ERROR o.s.i.handler.LoggingHandler - org.springframework.messaging.MessagingException: Problem occurred while synchronizing remote to local directory; nested exception is org.springframework.messaging.MessagingException: Failed to obtain pooled item; nested exception is java.lang.IllegalStateException: failed to create SFTP Session
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:303)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:200)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:62)
    at org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:134)
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:224)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:245)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:58)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:190)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:186)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:353)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:344)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.messaging.MessagingException: Failed to obtain pooled item; nested exception is java.lang.IllegalStateException: failed to create SFTP Session
    at org.springframework.integration.util.SimplePool.getItem(SimplePool.java:178)
    at org.springframework.integration.file.remote.session.CachingSessionFactory.getSession(CachingSessionFactory.java:123)
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:441)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:264)
    ... 22 more
Caused by: java.lang.IllegalStateException: failed to create SFTP Session
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:393)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:57)
    at org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:81)
    at org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:78)
    at org.springframework.integration.util.SimplePool.doGetItem(SimplePool.java:188)
    at org.springframework.integration.util.SimplePool.getItem(SimplePool.java:169)
    ... 25 more
Caused by: java.lang.IllegalStateException: failed to connect
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:273)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:388)
    ... 30 more
Caused by: com.jcraft.jsch.JSchException: java.io.IOException: Pipe closed
    at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:315)
    at com.jcraft.jsch.Channel.connect(Channel.java:152)
    at com.jcraft.jsch.Channel.connect(Channel.java:145)
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:268)
    ... 31 more
Caused by: java.io.IOException: Pipe closed
    at java.io.PipedInputStream.read(PipedInputStream.java:307)
    at java.io.PipedInputStream.read(PipedInputStream.java:377)
    at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2909)
    at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2935)
    at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:262)
    ... 34 more