[ACCEPTED]-Apache Commons FTPClient.listFiles-ftp-client

Accepted answer
Score: 20

This seems like the same issue I had (and 1 solved), see this answer:

Apache Commons Net FTPClient and listFiles()

Score: 6

After I set the mode as PASV it is working fine 1 now! Thanks for all your efforts and suggestions!

Score: 2

I added client.enterLocalPassiveMode() and it works:

boolean login = client.login("xxx", "xxx");


Score: 1

Just a silly suggestion... can you do a 4 listing on the /uploads folder using a normal 3 FTP client. I ask this because some FTP 2 servers are setup to not display the listing 1 of an upload folder.

Score: 1

First, make sure the listing works in other 4 programs. If so, one possibility is that 3 the file listing isn't being parsed correctly. You 2 can try explicitly specifying the parser 1 to use with initiateListParsing.

Score: 1

I had to same problem and it turned out 4 to be that it couldn't parse what the server 3 was returning for a file listing. I this 2 line after connecting to the ftp server 1 ftpClient.setParserFactory(new MyFTPFileEntryParserFactory());

public class MyFTPFileEntryParserFactory implements FTPFileEntryParserFactory {
private final static FTPFileEntryParser parser = new UnixFTPEntryParser() {
    @Override public FTPFile parseFTPEntry(String entry) {
        FTPFile ftpFile = new FTPFile();
        return ftpFile;

@Override public FTPFileEntryParser createFileEntryParser(FTPClientConfig config) throws ParserInitializationException {
    return parser;

@Override public FTPFileEntryParser createFileEntryParser(String key) throws ParserInitializationException {
    return parser;


Score: 1

In my case, on top of applying enterLocalPassiveMode and indicating 3 correct operation system, I also need to 2 set UnparseableEntries to true to make the listFile method 1 work.

FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
boolean isLoginSuccess = client.login(username, password);

More Related questions