FTP connect problem with Jakarta Commons Net package

B

Barry

Hi,

Can somebody help me out on the following problem:

I am using the Jakarta Commons Net package to perform FTP operations.
I created a test program that connected to a remote AIX machine to
upload and download a file from my local machine (Windows XP). This
all works fine. However, now I uploaded the code to USS and the code
seems to freeze when executing the connect method of the FTPClient
class. Below is a code fragment.

ftpClient = new FTPClient();
log.info("1");
// Attach a listener to the client, so that the commands are
logged
ftpClient.addProtocolCommandListener(new
FTPCommandListener(logger));

try {
// Connect to the remote server
log.info("2a");
ftpClient.connect(settings.server, 21);
log.info(ftpClient.getReplyString());

// check reply code.
if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
ftpClient.disconnect();
log.info("Connection refused.");
return;
}

log.info("2b");
// Logon usgin the credentials
ftpClient.login(settings.userName,settings.password);

// Most remote servers are behing a firewall, so enable passive
mode
log.info("3");
if (settings.passiveMode) ftpClient.enterLocalPassiveMode();

// Check if the connection is established...
replyCommunication = ftpClient.getReplyCode();
log.info("4");
if (!FTPReply.isPositiveCompletion(replyCommunication))
{
ftpClient.disconnect();
throw new Exception("Connection failed");
}

The last debugging info printed is "2a".

I've tried different scenario's (host name/ip address, active/passive
mode, with and without port number), but so far the results are the
same. By the way: manually connecting to the remote machine using FTP
commands from the command prompt does work, so that's not the problem.

Can anyone help me out?

Best regards,

Barry
 
G

gimme_this_gimme_that

If you simply need to ftp something it's easiest to do it with an ANT
task.

With ANT you can do other useful things such as telent to the remote
host and delete the file before ftping it.

If you must code it, you might take a look at the code to the ANT
optional tasks jar.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top