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

vyswwuz2  于 2021-07-05  发布在  Java
关注(0)|答案(0)|浏览(478)

我有一个spring批处理应用程序,其中批处理连续运行,通过sftp从另一台服务器提取数据。在日志中,我不断得到下面提到的错误,但它似乎是批量工作的预期从另一个服务器拉文件没有任何问题。我不知道为什么它在日志中抛出错误。奇怪的是,同样的代码没有在qa env中抛出任何错误,它在prod中唯一的抛出错误。batch正在执行它的工作,但它的抛出错误也在日志中。
有谁能给我建议如何消除这个错误吗?
下面是创建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;**

pom条目:


**<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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题