Please be patient as I am not a java developer but I am the one in the office now trying to diagnose the problem. We have started creating a process where we send XML in a text file to an online job posting site using SFTP. The job posting site monitors the directories on their site and automatically updates the listed jobs. We tested this successfully internally using the jcraft sftp package. The files are not large, around 3Mb. When trying to run the procedure (which is called from an Oracle concurrent program) the process hangs for about 15 minutes (it should complete in under a minute if it was working) and transmits only about 500k of the file. I can switch the parameters to an internal server and it will sftp it correctly. For the external site, the log file in Oracle shows the line 'Here 17' (see below, sorry it does not print the stacktrace in Oracle for some reason) which I think means the process is erroring out in c.put(new FileInputStream(f), f.getName()); If anyone is familiar with the jcraft package, I would greatly appreciate any input as to why it would only transmit a portion of the file than stop. I should tell you that I have sent a smaller file correctly to the external site also, just not the full 3Mb file. I also know that they can handle a file that size because I can SFTP it to them from the command line. Does anyone have any clues as to what I should check?
import com.jcraft.jsch.*;
import java.io.*;
public class sendSftp {
public static String send( String ftpDest, String port, String user, String password, String remoteDir, String file )
{
int ftpPort = 22;
String step = "here 1";
try {
if ( ( ftpDest != null || !ftpDest.equals("") ) ||
( user != null || !user.equals("") ) ||
( password != null || !password.equals("") ) ||
( file != null || !file.equals("") ) )
{
return " Failure null input";
}
if ( port != null || !port.equals("") ) ftpPort = Integer.parseInt(port) ;
step = "Here 2";
JSch jsch = new JSch();
step = "Here 3";
Session session = null;
step = "Here 4";
Channel channel = null;
step = "Here 5";
ChannelSftp c = null;
step = "Here 6";
session = jsch.getSession(user, ftpDest, ftpPort);
step = "Here 7";
session.setPassword(password);
step = "Here 8";
java.util.Properties config = new java.util.Properties();
step = "Here 9";
config.put("StrictHostKeyChecking", "no");
step = "Here 10";
session.setConfig(config);
step = "Here 11";
session.connect();
step = "Here 12";
channel = session.openChannel("sftp");
step = "Here 13";
channel.connect();
step = "Here 14";
c = (ChannelSftp)channel;
step = "Here 15";
if ( remoteDir != null || !remoteDir.equals("") ) c.cd(remoteDir);
step = "Here 16";
File f = new File(file);
step = "Here 17";
c.put(new FileInputStream(f), f.getName());
step = "Here 18";
return "Success";
}catch (Exception e )
{
String err = e.getStackTrace().toString();
err = step + " Exception: " + err;
return err;
}
}
}
Edited by: sdhalepaska on Dec 24, 2008 12:14 PM