commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Kast" <>
Subject Commons Net FTPClient: initiateListParsing delivers empty result after migration from Windows to Linux
Date Mon, 06 Aug 2007 13:17:35 GMT

Hi all,

I use the FTPClient of Commons Net to retrieve files from
an FTP server and delete them after retrieval. This works
very well on my Windows 2000 Professional notebook using
a JDK 1.5.0.

However, if I move the java files to my target system
(Linux server) and recompile the code on JDK 1.4.2_11,
no files are fetched from the FTP server despite of
masses of files being available for retrieval (which
the Windows-based JVM process would fetch). 

"engine.hasNext()" delivers false so the code for file
retrieval is not executed.

Using a different parser (UnixFTPEntyParser) did not
yield a solution on Linux.

I would be more than glad if any of you could give me a hint
on how to solve this miracle.

Thanks in advance,


Code snippet is:

    FTPClient ftp = new FTPClient();
    ftp.connect( ftpServer );
    verifyFtpReply ( "connect to server", ftp.getReplyCode(),
    ftp.login( ftpUser, ftpPassword );
    verifyFtpReply ( "user/pwd login to server", ftp.getReplyCode(),
    timestampBefore = (new java.util.Date()).getTime();
    FTPListParseEngine engine = ftp.initiateListParsing();
    // fails as well: FTPListParseEngine engine =
arser", ftpRemoteDir);
    verifyFtpReply ( "initiateListParsing", ftp.getReplyCode(),
    timestampAfter = (new java.util.Date()).getTime();
    while (engine.hasNext()) {
        FTPFile[] files = engine.getNext(25);  // "page size" you want
        _log.debug("Found set of "+files.length+" files in remote dir
"+ftpRemoteDir + " (" + substrLess2(ftp.getReplyString())+")",
timestampBefore, timestampAfter);
    	for( int i=0; i<files.length; i++ ) {
    		if ( files[i] != null && files[i].isFile() ) {

                [...file retrieval...]



    private static String substrLess2 (String sourceStr) { 
        return sourceStr.substring(0,sourceStr.length()-2);
    private static void verifyFtpReply (String comment, int replyCode,
String replyString) throws Exception {
        if ( !FTPReply.isPositiveCompletion(replyCode) ) {
            throw new Exception ("FTP Error on "+comment+"

Linux version information

#uname -a
Linux testhost 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686
i686 i386 GNU/Linux
#java -version
java version "1.4.2_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_11-b06)
Java HotSpot(TM) Client VM (build 1.4.2_11-b06, mixed mode)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message