Spring integration spring集成:sftp入站适配器身份验证失败

Spring integration spring集成:sftp入站适配器身份验证失败,spring-integration,jsch,Spring Integration,Jsch,我使用sftp入站适配器每天8:00下载文件,因此为此,我将凭据(用户和密码)声明到文件user.properties中 执行此操作时身份验证失败,但如果我将密码直接写入application-context.xml,则验证成功 我的源代码: <bean id="defaultSftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory"

我使用sftp入站适配器每天8:00下载文件,因此为此,我将凭据(用户和密码)声明到文件user.properties中

执行此操作时身份验证失败,但如果我将密码直接写入application-context.xml,则验证成功

我的源代码:

  <bean id="defaultSftpSessionFactory"
        class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">

        <property name="host" value="${host}" />
        <property name="port" value="${port}" />
        <property name="user" value="${user}" />
        <property name="privateKey" value="${private.keyfile}"/>
        <property name="privateKeyPassphrase" value="${passphrase}"/>

        <property name="allowUnknownKeys" value="true" />
    </bean>


An exception is occured:

    LoggingHandler:145 - 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:266)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:193)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:59)
    at org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:134)
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:175)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:224)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:57)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:176)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:173)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:330)
    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:324)
    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(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
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.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:223)
    ... 22 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)
    ... 25 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)
    ... 30 more
Caused by: com.jcraft.jsch.JSchException: Auth cancel
    at com.jcraft.jsch.Session.connect(Session.java:511)
    at com.jcraft.jsch.Session.connect(Session.java:183)
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:263)
    ... 31 more

发生异常:
LoggingHandler:145-org.springframework.messaging.MessagingException:将远程目录同步到本地目录时出现问题;嵌套异常为org.springframework.messaging.MessaginException:无法获取池项目;嵌套异常为java.lang.IllegalStateException:未能创建SFTP会话
位于org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:266)
位于org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:193)
位于org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:59)
位于org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:134)
位于org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:175)
位于org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:224)
位于org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:57)
位于org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:176)
位于org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:173)
位于org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:330)
位于org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
位于org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
位于org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)
位于org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:324)
位于org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
位于org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
位于java.util.concurrent.Executors$RunnableAdapter.call(未知源)
位于java.util.concurrent.FutureTask.run(未知源)
位于java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(未知源)
位于java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(未知源)
位于java.util.concurrent.ThreadPoolExecutor.runWorker(未知源)
位于java.util.concurrent.ThreadPoolExecutor$Worker.run(未知源)
位于java.lang.Thread.run(未知源)
原因: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.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:223)
... 还有22个
原因: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)
... 25多
原因:java.lang.IllegalStateException:连接失败
位于org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:272)
位于org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:377)
... 30多
原因:com.jcraft.jsch.JSchException:Auth cancel
位于com.jcraft.jsch.Session.connect(Session.java:511)
位于com.jcraft.jsch.Session.connect(Session.java:183)
位于org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:263)
... 还有31个
以及jsch调试:

  jsch:52 - Connecting to 10.241.22.22 port 22
2015-12-22 08:35:04 INFO  jsch:52 - Connection established
2015-12-22 08:35:04 INFO  jsch:52 - Remote version string: SSH-2.0-xlightftpd_release_3.8.5.1
2015-12-22 08:35:04 INFO  jsch:52 - Local version string: SSH-2.0-JSCH-0.1.53
2015-12-22 08:35:04 INFO  jsch:52 - CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
2015-12-22 08:35:04 INFO  jsch:52 - aes256-ctr is not available.
2015-12-22 08:35:04 INFO  jsch:52 - aes192-ctr is not available.
2015-12-22 08:35:04 INFO  jsch:52 - aes256-cbc is not available.
2015-12-22 08:35:04 INFO  jsch:52 - aes192-cbc is not available.
2015-12-22 08:35:04 INFO  jsch:52 - CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
2015-12-22 08:35:04 INFO  jsch:52 - diffie-hellman-group14-sha1 is not available.
2015-12-22 08:35:04 INFO  jsch:52 - CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
2015-12-22 08:35:04 INFO  jsch:52 - SSH_MSG_KEXINIT sent
2015-12-22 08:35:04 INFO  jsch:52 - SSH_MSG_KEXINIT received
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: ssh-rsa
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: hmac-sha1
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: hmac-sha1
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: none
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: none
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: 
2015-12-22 08:35:04 INFO  jsch:52 - kex: server: 
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: none
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: none
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: 
2015-12-22 08:35:04 INFO  jsch:52 - kex: client: 
2015-12-22 08:35:04 INFO  jsch:52 - kex: server->client aes128-cbc hmac-sha1 none
2015-12-22 08:35:04 INFO  jsch:52 - kex: client->server aes128-cbc hmac-sha1 none
2015-12-22 08:35:04 INFO  jsch:52 - SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent
2015-12-22 08:35:04 INFO  jsch:52 - expecting SSH_MSG_KEX_DH_GEX_GROUP
2015-12-22 08:35:04 INFO  jsch:52 - SSH_MSG_KEX_DH_GEX_INIT sent
2015-12-22 08:35:04 INFO  jsch:52 - expecting SSH_MSG_KEX_DH_GEX_REPLY
2015-12-22 08:35:05 INFO  jsch:52 - ssh_rsa_verify: signature true
2015-12-22 08:35:05 INFO  jsch:52 - Host '10.241.22.22' is known and matches the RSA host key
2015-12-22 08:35:05 INFO  jsch:52 - SSH_MSG_NEWKEYS sent
2015-12-22 08:35:05 INFO  jsch:52 - SSH_MSG_NEWKEYS received
2015-12-22 08:35:05 INFO  jsch:52 - SSH_MSG_SERVICE_REQUEST sent
2015-12-22 08:35:05 INFO  jsch:52 - SSH_MSG_SERVICE_ACCEPT received
2015-12-22 08:35:05 INFO  jsch:52 - Authentications that can continue: password
2015-12-22 08:35:05 INFO  jsch:52 - Next authentication method: password
2015-12-22 08:35:05 INFO  jsch:52 - Disconnecting from 10.241.22.22 port 22
jsch:52-连接到10.241.22.22端口22
2015-12-22 08:35:04信息jsch:52-已建立连接
2015-12-22 08:35:04信息jsch:52-远程版本字符串:SSH-2.0-xlightftpd\u版本3.8.5.1
2015-12-22 08:35:04信息jsch:52-本地版本字符串:SSH-2.0-jsch-0.1.53
2015-12-22 08:35:04信息jsch:52-校验密码:aes256 ctr、aes192 ctr、aes128 ctr、aes256 cbc、aes192 cbc、aes128 cbc、3des ctr、ARCFORE、ARCFOR128、ARCFOR256
2015-12-22 08:35:04信息jsch:52-aes256中心不可用。
2015-12-22 08:35:04信息jsch:52-aes192中心不可用。
2015-12-22 08:35:04信息jsch:52-aes256 cbc不可用。
2015-12-22 08:35:04信息jsch:52-
<context:property-placeholder location="classpath:user.properties"/>