本文介绍了com.jcraft.jsch.JSchException:验证:false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 https:/中给出的代码/github.com/spring-projects/spring-integration-samples/tree/master/basic/sftp ,当我在Eclipse中运行测试时,它通过了,但是当我通过maven尝试时(mvn clean编译测试),但在下面的堆栈跟踪中失败了

I am trying the code given at https://github.com/spring-projects/spring-integration-samples/tree/master/basic/sftp, and when i am running the test in Eclipse it get passed but when i am trying it through maven(mvn clean compile test) it is getting failed with below stack trace

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:118)
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:332)
    at org.springframework.integration.samples.sftp.SftpTestUtils.createTestFiles(SftpTestUtils.java:25)
    at org.springframework.integration.samples.sftp.SftpInboundAdapterTest.assertFilePattern(SftpInboundAdapterTest.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:619)
    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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    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.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.IllegalStateException: failed to create SFTP Session
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:355)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:49)
    at org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:76)
    at org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:73)
    at org.springframework.integration.util.SimplePool.doGetItem(SimplePool.java:188)
    at org.springframework.integration.util.SimplePool.getItem(SimplePool.java:169)
    ... 29 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:350)
    ... 34 more
Caused by: com.jcraft.jsch.JSchException: verify: false
    at com.jcraft.jsch.Session.connect(Session.java:330)
    at com.jcraft.jsch.Session.connect(Session.java:183)
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:263)
    ... 35 more

无法理解出了什么问题

在pom中刚刚添加了以下插件

In the pom just added the below plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.16</version>
    <configuration>
        <reuseForks>false</reuseForks>
        <forkCount>1</forkCount>
    </configuration>
</plugin>

添加了日志文件行
在Eclipse中

Added Log File line
In Eclipse

2015-07-17 19:15:33 jsch [INFO] expecting SSH_MSG_KEXDH_REPLY
2015-07-17 19:15:33 jsch [INFO] ssh_dss_verify: signature true

在Maven中

2015-07-17 19:13:26 jsch [INFO] expecting SSH_MSG_KEXDH_REPLY
2015-07-17 19:13:26 ServerSession [INFO] Kex: server->client aes128-ctr hmac-md5 none
2015-07-17 19:13:26 ServerSession [INFO] Kex: client->server aes128-ctr hmac-md5 none
2015-07-17 19:13:26 jsch [INFO] ssh_dss_verify: signature false

推荐答案

不幸的是,来自jsch的verify: false只是一个包罗万象的出了点问题".我建议您查看服务器日志.

Unfortunately, verify: false from jsch is just a catch-all "something went wrong". I suggest you look at the server logs.

此外,打开调试jsch的日志记录并比较eclipse和maven之间的输出.

Also, turn on debug logging for jsch and compare the output between eclipse and maven.

是否正在使用其他密钥文件?

Perhaps a different key file is being used?

这篇关于com.jcraft.jsch.JSchException:验证:false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 12:07