Spring integration 动态SFTP出站适配器解析器

Spring integration 动态SFTP出站适配器解析器,spring-integration,Spring Integration,我正在处理一个需要使用Spring SFTP适配器将文件发送到多个目的地的需求。所以我想创建一个类似于动态FTP示例的动态SFTP解析器。但它不能正常工作。我得到以下例外情况 org.springframework.messaging.MessagingException: Dispatcher failed to deliver Message; nested exception is org.springframework.messaging.MessagingException: Fa

我正在处理一个需要使用Spring SFTP适配器将文件发送到多个目的地的需求。所以我想创建一个类似于动态FTP示例的动态SFTP解析器。但它不能正常工作。我得到以下例外情况

  org.springframework.messaging.MessagingException: Dispatcher failed to deliver Message; 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.dispatcher.AbstractDispatcher.wrapExceptionIfNecessary(AbstractDispatcher.java:133)
    at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:120)
    at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147)
    at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120)
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392)
    at org.springframework.integration.samples.ftp.DynamicFtpChannelResolver.createNewCustomerChannel(DynamicFtpChannelResolver.java:109)
    at org.springframework.integration.samples.ftp.DynamicFtpChannelResolver.resolve(DynamicFtpChannelResolver.java:91)
    at org.springframework.integration.samples.ftp.DynamicFtpChannelResolverTests.testResolve(DynamicFtpChannelResolverTests.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
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:408)
    at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:282)
    at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:272)
    at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:264)
    at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:142)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
    at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
    ... 31 more
Caused by: java.lang.IllegalStateException: failed to create SFTP Session
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:382)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:55)
    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)
    ... 39 more
Caused by: java.lang.IllegalStateException: failed to connect
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:272)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:377)
    ... 44 more
Caused by: com.jcraft.jsch.JSchException: reject HostKey: <HOST>
    at com.jcraft.jsch.Session.checkHost(Session.java:791)
    at com.jcraft.jsch.Session.connect(Session.java:342)
    at com.jcraft.jsch.Session.connect(Session.java:183)
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:263)
    ... 45 more
org.springframework.messaging.MessaginException:调度程序无法传递消息;嵌套异常为org.springframework.messaging.MessaginException:无法获取池项目;嵌套异常为java.lang.IllegalStateException:未能创建SFTP会话
位于org.springframework.integration.dispatcher.AbstractDispatcher.WrapeExceptionIfRequired(AbstractDispatcher.java:133)
位于org.springframework.integration.dispatcher.AbstractDispatcher.tryoOptimizedDispatch(AbstractDispatcher.java:120)
位于org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147)
位于org.springframework.integration.dispatcher.UnicastingDispatcher.dispatcher(UnicastingDispatcher.java:120)
位于org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
位于org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442)
位于org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392)
位于org.springframework.integration.samples.ftp.DynamicFtpChannelResolver.createNewCustomerChannel(DynamicFtpChannelResolver.java:109)
位于org.springframework.integration.samples.ftp.dynamicftpcchannelresolver.resolve(dynamicftpcchannelresolver.java:91)
位于org.springframework.integration.samples.ftp.dynamicftpcchannelresolvertests.testResolve(dynamicftpcchannelresolvertests.java:36)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:497)
位于org.junit.runners.model.FrameworkMethod$1.runReflectVeCall(FrameworkMethod.java:47)
位于org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
位于org.junit.runners.model.FrameworkMethod.invokeeexplosive(FrameworkMethod.java:44)
位于org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
位于org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
位于org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
位于org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
位于org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
位于org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
位于org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
访问org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
位于org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
位于org.junit.runners.ParentRunner.run(ParentRunner.java:309)
位于org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
位于org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
原因:org.springframework.messaging.MessagineException:获取池项目失败;嵌套异常为java.lang.IllegalStateException:未能创建SFTP会话
位于org.springframework.integration.util.SimplePool.getItem(SimplePool.java:178)
位于org.springframework.integration.file.remote.session.CachingSessionFactory.getSession(CachingSessionFactory.java:123)
位于org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:408)
位于org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:282)
位于org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:272)
位于org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:264)
位于org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:142)
位于org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
位于org.springframework.integration.dispatcher.AbstractDispatcher.tryoOptimizedDispatch(AbstractDispatcher.java:116)
... 还有31个
原因:java.lang.IllegalStateException:无法创建SFTP会话
位于org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:382)
位于org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:55)
位于org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:81)
位于org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:78)
位于org.springframework.integration.util.SimplePool.doGetItem(SimplePool.java:188)
位于org.springframework.integration.util.SimplePool.getItem(SimplePool.java:169)
... 39多
原因:java.lang.IllegalStateException:连接失败
位于org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:272)
位于org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:377)
... 44多
原因:com.jcraft.jsch.JSchException:拒绝主机密钥