Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
13.1k views
in Java FTP by (160 points)
Hello,

I tried to connect on the proFTPD 1.2.8 server and when I execute my java
application I've the following error message :

java.text.ParseException: Unparseable date: "drwxr-xr-x 3"
at java.text.DateFormat.parse(DateFormat.java:335)
at com.enterprisedt.net.ftp.WindowsFileParser.parse(WindowsFileParser.java:107)
at com.enterprisedt.net.ftp.FTPFileFactory.parse(FTPFileFactory.java:196)
at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:1816)
at test.TestEdtFtp.main(TestEdtFtp.java:25)

Here is my java code :

package test;

import com.enterprisedt.net.ftp.*;

public class TestEdtFtp
{
public static void main(String[] args)
{

//
//here is example code
//
String server = "192.168.0.1";
String user = "test";
String passwd = "test";
//
try
{
FTPClient ftpConnect = new FTPClient(server) ;
ftpConnect.login(user, passwd);
FTPFile[] files = ftpConnect.dirDetails("tmp") ;

for (int i = 0 ; i < files.length ; i++)
{
System.out.print(files[i].getName() + " -- ");
System.out.print(files[i].getType() + " -- ");
//System.out.print(files[i].lastModified().toString() + " -- ");
System.out.print(files[i].size());
}

ftpConnect.quit();

}
catch (Exception e)
{
e.printStackTrace();
}
}
}

The server run with the mandrake linux distribution. The tmp directory exist in the user test root directory.

Someone have an idea ?

Thanks,

13 Answers

0 votes
by (162k points)
Can you try forcing the use of the Unix parser just to see if it works correctly? There's a few posts that explain how to do so.
0 votes
by (180 points)
After forcing the usage of the UnixFileParser via setFTPFileFactory() and setting the locale via setParserLocale(), everything is working fine.

Below the DEBUG traces showing the error.
What seems to happen is the following:
- default unix file parser is used at the beginning
- since locale parser is not set, the parse of the date fails
- edtftp tries to switch from Unix to Windows parser
- parse fails again because of wrong parser
=> exception is raised with the error of the second try (with window parser)
I think the exception raised is misleading because it really seems the wrong parser is used, while in fact the first attempt was made with the correct unix parser.

Anyway thanks a lot for your support.
Alberto

08/05/2006 15:15:00:468 INFO [Thread-47] [NativeMethodAccessorImpl.invoke0] edtFTPj version: 1.5.2
08/05/2006 15:15:00:468 INFO [Thread-47] [NativeMethodAccessorImpl.invoke0] edtFTPj build timestamp: 20-Sep-2005 10:43:01 BST
08/05/2006 15:15:00:468 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] Connecting to /192.168.101.21:21
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 220 WFTPD 2.0 service (by Texas Imperial Software) ready for new user
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] ---> USER mas22
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 331 Give me your password, please
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] ---> PASS ********
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 230 Logged in successfully
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] ---> CWD .\
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 250 "D:\MAS\SWRELEASES" is current directory
08/05/2006 15:15:00:484 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] ---> CWD br
08/05/2006 15:15:00:500 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 250 "D:\MAS\SWRELEASES\br" is current directory
08/05/2006 15:15:00:500 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] ---> CWD rai
08/05/2006 15:15:00:500 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 250 "D:\MAS\SWRELEASES\br\rai" is current directory
08/05/2006 15:15:00:500 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] ---> QUIT
08/05/2006 15:15:00:500 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 221 Windows FTP Server (WFTPD, by Texas Imperial Software) says goodbye
08/05/2006 15:15:00:500 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] Connecting to /192.168.101.21:21
08/05/2006 15:15:00:515 DEBUG [Thread-47] [NativeMethodAccessorImpl.invoke0] 220 WFTPD 2.0 service (by Texas Imperial Software) ready for new user
08/05/2006 15:15:00:515 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> USER mas22
08/05/2006 15:15:00:515 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 331 Give me your password, please
08/05/2006 15:15:00:515 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> PASS ********
08/05/2006 15:15:00:515 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 230 Logged in successfully
08/05/2006 15:15:00:515 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> CWD .\
08/05/2006 15:15:00:515 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 250 "D:\MAS\SWRELEASES" is current directory
08/05/2006 15:15:00:515 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> CWD br
08/05/2006 15:15:00:531 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 250 "D:\MAS\SWRELEASES\br" is current directory
08/05/2006 15:15:00:531 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> CWD rai
08/05/2006 15:15:00:531 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 250 "D:\MAS\SWRELEASES\br\rai" is current directory
08/05/2006 15:15:00:531 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> SYST
08/05/2006 15:15:00:531 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 215 MSDOS A N (WFTPD by Texas Imperial Software)
08/05/2006 15:15:00:546 WARN [Thread-47] [NativeMethodAccessorImpl.invoke0] Unknown SYST 'MSDOS A N (WFTPD by Texas Imperial Software)' - defaulting to Unix parsing
08/05/2006 15:15:00:546 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> PORT 192,168,101,20,12,152
08/05/2006 15:15:00:546 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 200 PORT command okay
08/05/2006 15:15:00:546 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] ---> LIST
08/05/2006 15:15:00:562 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 150 File Listing Follows in ASCII mode
08/05/2006 15:15:00:703 DEBUG [Thread-47] [GeneratedMethodAccessor44.invoke] 226 Transfer finished successfully.
08/05/2006 15:15:00:703 INFO [Thread-47] [NativeMethodAccessorImpl.invoke0] Failed to parse listing 'drwxrwxrwx 1 noone nogroup 0 May 8 12:20 .': Unparseable date: "May-8-2006-12:20"
08/05/2006 15:15:00:703 INFO [Thread-47] [NativeMethodAccessorImpl.invoke0] Rotated parser to Windows
08/05/2006 15:15:00:703 ERROR [Thread-47] [SystemException.<init>] [1147094100703.0] java.text.ParseException: Unparseable date: "drwxrwxrwx 1"
0 votes
by (500 points)
I tried different configuration and concluded that the lone thing I had to set was the ParserLocale, it didn't matter if I didn't set the ftpfactoryfile, I just needed the following code line

client.setParserLocale(Locale.US);

then dirDetails() may be correctly invoked.

Anyway setting both the Locale and the correct ftpfactoryfile surely works in any case, even if it seems to me that the setting of the ftpfactoryfile is automatic or not mandatory; I found no way to know which is the server Locale, that's a parameter you have to know

Categories

...