Я использую входящий адаптер sftp для загрузки файлов каждый день в 8:00, поэтому для этого я объявляю учетные данные (пользователь и пароль) в файл user.properties.Весенняя интеграция: ошибка аутентификации входящего адаптера sftp
аутентификация не удалась при выполнении этого, но приступить, если я пишу пароль непосредственно в 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
и 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
Я уже сделал это. но проблема возникла при вводе пароля в user.properties. Если я помещаю его в файл config.xml, он работает успешно. – NAZEHA
Ну. Или ваши 'user.properties' находятся в неправильном месте, или вы делаете что-то другое немного неправильно. Поделитесь, пожалуйста, с StackTrace по этому вопросу и журналом 'DEBUG' для' org.springframework' с момента запуска приложения. Убедитесь, что вы используете 'ignore-resource-not-found/ignore-unresolvable' пару как' false' в ''. –
yes ignore-resource-not-found/ignore-unresolvable false – NAZEHA