Hi,
I'm trying to execute a java callout to connect to a sftp server. I'm using com.jcraft.jsch.JSch jar for connecting to the server. I did some trial and error and found that the callout is failing as i'm initializing the obect JSch jsch = new JSch();
There are no logs that i can provide here. Sample code that i have used is below:
JSch jsch = new JSch(); String knownHostsFilename = "/home/username/.ssh/known_hosts"; jsch.setKnownHosts( knownHostsFilename ); Session session = jsch.getSession( "remote-username", "remote-host" ); { // "interactive" version // can selectively update specified known_hosts file // need to implement UserInfo interface // MyUserInfo is a swing implementation provided in // examples/Sftp.java in the JSch dist UserInfo ui = new MyUserInfo(); session.setUserInfo(ui); // OR non-interactive version. Relies in host key being in known-hosts file session.setPassword( "remote-password" ); } session.connect(); Channel channel = session.openChannel( "sftp" ); channel.connect(); ChannelSftp sftpChannel = (ChannelSftp) channel; sftpChannel.get("remote-file", "local-file" ); // OR InputStream in = sftpChannel.get( "remote-file" ); // process inputstream as needed sftpChannel.exit(); session.disconnect();
Solved! Go to Solution.
It's possible that constructor is doing something that Apigee Edge prohibits. If so your code would see a permissions exception and you'd be able to catch it and set a context variable containing the stack trace.
To avoid the limitation, I suggest doing the FTP bit in something like nodejs. Is that feasible?