Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
8.9k views
in Java FTP by
Hey

Im trying to run ftp-client on unix and after listing directory im trying get files using get(String,String) method. Ive tested the program on Windows XP and it works fine, but on Unix I get following exception:
Exception in java_ftp_loader:

Retrieving by ebid: /n
BEL8903FF6B342E4CFD93E970B0A9B6A47E
java.io.IOException: Unexpected null reply received
        at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:621)
        at com.enterprisedt.net.ftp.FTPClient.validateTransfer(FTPClient.java:868)
        at com.enterprisedt.net.ftp.FTPClient.get(FTPClient.java:1194)
        at mypackage1.java_ftp_loader.main(java_ftp_loader.java:57)
Unexpected null reply received
java.io.IOException: Unexpected null reply received


Here's the code im using to implement the edtftpj.
public static void main(String[] args)
  {
    java_ftp_loader java_ftp_loader = new java_ftp_loader();
    String host = "**********";
    String user = "******";
    String password = "*****";
    
     
    FTPClient ftp = null;
    try 
    {
      
      ftp = new FTPClient(host, 21);
      FTPMessageCollector listener = new FTPMessageCollector();
      ftp.setMessageListener(listener);
    
      ftp.login(user,password);
      
      FTPFileFactory ffact = new FTPFileFactory(FTPFileFactory.UNIX_STR);
      ftp.setFTPFileFactory(ffact);
      ftp.setType(FTPTransferType.BINARY);
      String[] listaus = ftp.dir("/***/***");
         
      for (int i = 0; i < listaus.length ; i ++) 
      {
        
        
        String hak = listaus[i];
        System.out.println(listaus[i]);
        StringTokenizer tok = new StringTokenizer(hak,"/");
        String turha = tok.nextToken();
        String turha2 = tok.nextToken();
        String ebid = tok.nextToken();

        System.out.println("Retrieving by ebid: /n");
        System.out.println(ebid);
       
        ftp.get(ebid + ".xml","bills-new/by-ebid/" + ebid +"/data.einvoicexml");
        
   }


The ftp-server which im connecting into is using virtual-directories so thats why im using StringTokenizer to get identifier for file im retrieving. I get the exception-message after listing (it retrieves one file but after that it throws the exception).

Could someone help me with this, and give me some suggestions what could be wrong? I would appreciate that very much.... Thank you :D

6 Answers

0 votes
by (162k points)
How many files are involved?

Hey

Im trying to run ftp-client on unix and after listing directory im trying get files using get(String,String) method. Ive tested the program on Windows XP and it works fine, but on Unix I get following exception:
0 votes
by
How many files are involved?

Hey

Im trying to run ftp-client on unix and after listing directory im trying get files using get(String,String) method. Ive tested the program on Windows XP and it works fine, but on Unix I get following exception:


I don't exactly know. At least six files. Im trying to create concurrent program which would log to ftp-server and check if new files exists and then dowload them. And on windows this works fine but
0 votes
by
I modified the code in the main block so that its trying to retrieve only one file. Sometimes the program just halts after message :
Line is : 150 Opening BINARY mode data connection for /cache/0000000032 (2888 bytes) 

And sometimes it throws exception:
 
BEL83B56B56502F44EEAF246887EC743076
this is the indentifier which is the name of the file im trying to retrieve.

I modified the FTPControlSocket code so that it prints out the line from the BufferedReader. Here's the exception:



Line is : 200 PORT command successful.
Line is : 150 Opening BINARY mode data connection for /cache/0000030489 (2888 bytes)
Line is : null
Exception in java_ftp_loader:
java.io.IOException: Unexpected null reply received
        at mypackage1.FTPControlSocket.readReply(FTPControlSocket.java:623)
        at mypackage1.FTPClient.validateTransfer(FTPClient.java:868)
        at mypackage1.FTPClient.get(FTPClient.java:1194)
        at mypackage1.java_ftp_loader.main(java_ftp_loader.java:77)
Unexpected null reply received
java.io.IOException: Unexpected null reply received


Why the buffered reader has one line null? This throws the exception but can change this? And why sometimes it doesnt throw this exception and just halts?

Thank you if you can help me...
0 votes
by (162k points)
Maybe try cd'ing to the directory you want to list?

[quote="TT"][/quote]
0 votes
by
I cant do that because directories are only virtual directories.
0 votes
by (162k points)
? you should still be able to cd to them remotely

I cant do that because directories are only virtual directories.

Categories

...