camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Goyal, Arpit" <arpit.go...@sap.com>
Subject Unable to connect from camel-ftp to apache mina-sshd
Date Sat, 03 Sep 2016 05:52:19 GMT
Hi Colleagues,

I am trying a very simple scenario where I am hosting apache mina-sshd as SFTP Server in my
UNIT Test. Any one has idea why connection to SFTP always fails?

Camel ftp - 2.16.3
Apache mina sshd - 1.2.0

Regards,
Arpit.


My Camel Route in test case
-------------------------------------
from("direct:xxx").process("new MyProcessor()").to("sftp:localhost:9696?username=...&password=....&[options]")


ERROR:
-----------
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://dummy@localhost:9696
                at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146)
                at org.apache.camel.component.file.remote.RemoteFileProducer.connectIfNecessary(RemoteFileProducer.java:209)
                at org.apache.camel.component.file.remote.RemoteFileProducer.recoverableConnectIfNecessary(RemoteFileProducer.java:201)
                at org.apache.camel.component.file.remote.RemoteFileProducer.preWriteCheck(RemoteFileProducer.java:133)
                at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:113)
Caused by: com.jcraft.jsch.JSchException: failed to send channel request
                at com.jcraft.jsch.Request.write(Request.java:65)
                at com.jcraft.jsch.RequestSftp.request(RequestSftp.java:47)
                at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:237)
                at com.jcraft.jsch.Channel.connect(Channel.java:152)
                at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:130)
                ... 74 more

Test case Parent class - all children start camel route as given above
--------------------------------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.util.Arrays;

import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.file.virtualfs.NativeFileSystemFactory;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.password.PasswordAuthenticator;
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.scp.ScpCommandFactory;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystem;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

public abstract class AbstractSftpServerTest {

 private static SshServer sftpServer;
  private static final String TEMP_FOLDER = System.getProperty("java.io.tmpdir");
  private static File tempFolder;
  private static File tempFile;

  protected static final int PORT = 9696;

  @BeforeClass
  public static void beforeClass() throws IOException {
    sftpServer = SshServer.setUpDefaultServer();
    sftpServer.setHost("localhost");
    tempFolder = new File(TEMP_FOLDER);
    tempFile = File.createTempFile("server", ".key", tempFolder);
    sftpServer.setPort(PORT);
    sftpServer.setFileSystemFactory(new NativeFileSystemFactory ());
    sftpServer.setCommandFactory(new ScpCommandFactory());
    sftpServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(tempFile));

    sftpServer.setPasswordAuthenticator(new PasswordAuthenticator() {

      @Override
      public boolean authenticate(String username, String password, ServerSession session)
throws PasswordChangeRequiredException {
          return true;
      }
    });
    sftpServer.start();
  }


  @AfterClass
  public void afterClass() throws IOException {
    sftpServer.stop();
    tempFile.delete();
  }
}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message