Announcement Announcement Module
No announcement yet.
DefaultSftpSessionFactory not working in 2.0.6 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultSftpSessionFactory not working in 2.0.6

    Hello, I am trying to open a sftp session using Spring Integration version 2.0.6. This is as described in the jira issue -

    Per the fix versions label in JIRA the issue should've been fixed in both 2.0.6 and 2.1.1. I was able to get the code below to work in 2.1.1 but not in 2.0.6.

    Here's the simple sample code -
            DefaultSftpSessionFactory sftpSessionFactory = new DefaultSftpSessionFactory();
    Here's the Log and the exception -
    [email protected]:26:57.597 INFO  [main] (     - Connecting to localhost port 22
    [email protected]:26:57.602 INFO  [main] (     - Connection established
    [email protected]:26:57.616 INFO  [main] (     - Remote version string: SSH-2.0-OpenSSH_5.6
    [email protected]:26:57.616 INFO  [main] (     - Local version string: SSH-2.0-JSCH-0.1.42
    [email protected]:26:57.617 INFO  [main] (     - CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
    [email protected]:26:57.768 INFO  [main] (     - SSH_MSG_KEXINIT sent
    [email protected]:26:57.768 INFO  [main] (     - SSH_MSG_KEXINIT received
    [email protected]:26:57.769 INFO  [main] (     - kex: server->client aes128-ctr hmac-md5 none
    [email protected]:26:57.770 INFO  [main] (     - kex: client->server aes128-ctr hmac-md5 none
    [email protected]:26:57.779 INFO  [main] (     - SSH_MSG_KEXDH_INIT sent
    [email protected]:26:57.779 INFO  [main] (     - expecting SSH_MSG_KEXDH_REPLY
    [email protected]:26:57.792 INFO  [main] (     - ssh_rsa_verify: signature true
    [email protected]:26:57.795 WARN  [main] (     - Permanently added 'localhost' (RSA) to the list of known hosts.
    [email protected]:26:57.795 INFO  [main] (     - SSH_MSG_NEWKEYS sent
    [email protected]:26:57.795 INFO  [main] (     - SSH_MSG_NEWKEYS received
    [email protected]:26:57.798 INFO  [main] (     - SSH_MSG_SERVICE_REQUEST sent
    [email protected]:26:57.799 INFO  [main] (     - SSH_MSG_SERVICE_ACCEPT received
    [email protected]:26:57.801 INFO  [main] (     - Authentications that can continue: publickey,keyboard-interactive,password
    [email protected]:26:57.801 INFO  [main] (     - Next authentication method: publickey
    [email protected]:26:57.802 INFO  [main] (     - Authentications that can continue: keyboard-interactive,password
    [email protected]:26:57.802 INFO  [main] (     - Next authentication method: keyboard-interactive
    [email protected]:26:57.811 INFO  [main] (     - Disconnecting from localhost port 22
    java.lang.IllegalStateException: failed to create SFTP Session
    	at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(
    	at org.springframework.integration.samples.sftp.SftpOutboundTransferSample.testSftpConnection(
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    	at java.lang.reflect.Method.invoke(
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(
    	at org.junit.runners.ParentRunner.runLeaf(
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    	at org.junit.runners.ParentRunner$
    	at org.junit.runners.ParentRunner$1.schedule(
    	at org.junit.runners.ParentRunner.runChildren(
    	at org.junit.runners.ParentRunner.access$000(
    	at org.junit.runners.ParentRunner$2.evaluate(
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
    Caused by: java.lang.IllegalStateException: failed to connect
    	at org.springframework.integration.sftp.session.SftpSession.connect(
    	at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(
    	... 24 more
    Caused by: com.jcraft.jsch.JSchException: Auth cancel
    	at com.jcraft.jsch.Session.connect(
    	at com.jcraft.jsch.Session.connect(
    	at org.springframework.integration.sftp.session.SftpSession.connect(
    	... 25 more
    Can someone please let me know if this is indeed fixed in 2.0.6? If so, am I missing something?

    I really dont want to go with the alternate route of upgrading the whole project to 2.1.1 (Which from my tests require spring core upgrade to 3.0.7 as well).

    Thanks and regards,

  • #2
    I'd say it would be nice if you can try 2.1.1 (just for the sake of trying) but the issue indeed was backported and looking at your trace it seems to me you are having some other issue. The message you showing is:
    Caused by: com.jcraft.jsch.JSchException: Auth cancel
    I am not sure where its coming from and why and what is canceling your authentication attempt.
    Can you SSH to the host with the same credentials?
    Can you provide more details as to how you access the host outside SI?


    • #3
      Hi Oleg, thank you for your reply. I can ssh to the host with same credentials via terminal and I also tested the same code successfully on 2.1.1.

      The code eventually will be used via int-sftp:outbound-channel-adapter by defining org.springframework.integration.sftp.session.Defau ltSftpSessionFactory as spring bean. Ever since I've came across this error I am trying to test this very basic connectivity problem, using the code I've posted earlier.


      • #4
        2.1.1 uses jsch 0.1.45; 2.0.6 uses 0.1.42.

        I was able to reproduce your problem with 2.0.6; upgrading jsch to 0.1.45 fixes the problem; add...

        		</dependency> your pom.


        • #5
          DefaultSftpSessionFactory not working in 2.0.6 [Solved]

          That seems to have done the trick. Its working now.

          Thank you Oleg and Gary for quick replies.

          Last edited by bn.shyam; Jun 1st, 2012, 08:29 AM.