aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes problem retrieving a zip file from FTP server using org.apache.commons.net.ftp. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "problem retrieving a zip file from FTP server using org.apache.commons.net.ftp." Watch "problem retrieving a zip file from FTP server using org.apache.commons.net.ftp." New topic
Author

problem retrieving a zip file from FTP server using org.apache.commons.net.ftp.

esha sharma
Greenhorn

Joined: Jan 02, 2009
Posts: 6
here is the problem
I am trying to retrieve a zip file from FTP server and after retriveing few MB of data (aprx 22MB) it hangs and doesnt move further... the same code works fine for another files except zip file...
i m using ftpclient.retrieveFile(filename, fos)
where filename is name of the file that i m trying to retrieve...n fos is FileOutputStream....
any help would be appreciated..
[ January 02, 2009: Message edited by: esha sharma ]
esha sharma
Greenhorn

Joined: Jan 02, 2009
Posts: 6
I am still waiting for answer...
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8873
    
    8

From our FAQ, PatienceIsAVirtue:

And if you finally decide to bump the post, please try to do so by posting more information! After all, if nobody answered, that's probably because nobody did know an answer. You had 24 hours to do your own research in the mean time - show us that you used them, and give us new things to think about. If nothing else, work harder to TellTheDetails.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
esha sharma
Greenhorn

Joined: Jan 02, 2009
Posts: 6
thank you for the reply.
Joe, before coming to this forum i googled for this problem...but could not get any answer to solve this problem..
So I thought i might get some answer here...
I would like to elaborate the problem...
I am trying to retrieve a zip file from FTP server and the size of zip file is apx 67MB. For that I am using org.apache.commons.net.ftp.FTPClient class. Everytime it fetches that file till 22MB and stuck there...it does not do anything and program stuck there...
please let me know if i am doing something wrong...the same code works fine if i retrieve any othere file...
one more question, is there any limitation for file size?
please let me know, is there anything that i need to mention here?
thank you
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8873
    
    8

There is no limitation on the size of a file. Can you show us your code?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4180
    
  21

Perhaps you can show the code you are using to retrieve the file and what you do with it after it is downloaded.

As for limits, do you control the FTP server hosting the file? What do you know about it's configuration? Can you access the FTP sites logs to see if there is an error, warning, or message? What happens when you try to download the file with a traditional FTP client?

Do you catch exceptions and log them? Have you checked the logs to see if an exception occurs? Is it just one particular ZIP file that causes the problem or all ZIP files above a certain size? When you say it works on other file types did you test with other files that where just as large as the ZIP file?

You don't actually have to answer all these questions on this thread, but they are the sort of questions you should test to try to get yourself closer to an answer. Many of them will be relevant to the problem and when you address them you are likely to find a key answer that helps solve the issue. So please do go through the steps of checking all of these things. When you post back please show the code and any answers to the questions above that may be relevant.

Steve


Steve
esha sharma
Greenhorn

Joined: Jan 02, 2009
Posts: 6
************************source code***********************

************************end of source code***********************


1) The zip contains files, using these files I am updating some tables.

2) do you control the FTP server hosting the file?
No I do not.

3) What do you know about it's configuration?
I do not have other information except host name, user name, password.

4) Can you access the FTP sites logs to see if there is an error, warning, or message?
No I cannot access.


5) What happens when you try to download the file with a traditional FTP client?
I have tried downloading that file through FTP Client software; I can download everything without any problem. I have noticed that file size is different while using both procedures (using program and FTP Client software).

6) Do you catch exceptions and log them?
Yes, I do. No exception no error message. It does not do anything. Like stuck in infinite loop.

7) Is it just one particular ZIP file that causes the problem or all ZIP files above a certain size?
When I try to download another zip file with smaller size, first, it does not download complete file. Second, when I try to open that zip file, it gives error message, “Error: Unexpected end of archive file”. And when I try to unzip that file I get another error message “file is corrupted.”
All the other files (which are not zip files) on FTP server are below 22MB, so I am not sure about that.

Thank you!

JCE: Please Use Code Tags
esha sharma
Greenhorn

Joined: Jan 02, 2009
Posts: 6
i have tried using retrieveFileStream()....and then copied the stream using copyStream() method....but i hv noticed that its blocked and doing nothing (not even giving any error message) because it is waiting to read next byte from InputStream. As it is not getting anything from inputstream so its waiting....Please let me know, if anything could be done in this situation...
Thank you!
hvt kg
Greenhorn

Joined: Aug 19, 2009
Posts: 1
Hi, esha sharm.

I am new bie.
I had problems the same. Can you post your code. which is tries?

Regrads
hvt_kg
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"hvt kg" welcome to Javaranch
please check your private messages. You can check them by clicking the My Private Messages link above.
Also take a look at NotACodeMill


SCJP, SCWCD.
|Asking Good Questions|
Bernie Barnard
Greenhorn

Joined: Nov 12, 2009
Posts: 1
Today I was having the same problem. I was downloading zip files from a site and some files were coming back smaller than those on the FTP server. Curiously, it was working fine on my Windows desktop, but not on my linux server. Solved the problem by FTPClient.setFileType(FTP.BINARY...). Try it!.
Achyuth Nambiar
Greenhorn

Joined: May 11, 2006
Posts: 2
Hi,

I am facing the same problem.
While downloading the zip file from an ftp site, it just goes on into infinite loop.

The code is same as what Esha has.

The below code did not work for me.

Could you please let me know how to approach this issue?

Thank you
Achyuth
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

So when it 'hangs' , does your entire flow stop.
I mean you never come out of the try block ?

And does it happen with this precise file or with files > size of this one ?
Trying some other larger file might help understand if its an issue with the file size.

Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
Achyuth Nambiar
Greenhorn

Joined: May 11, 2006
Posts: 2

Hi Ani,

Thank you for your reply.

When it hangs it does NOT stop the flow. It just continues as it in an infinite loop. It never comes out of the try block.

The similar file with the same size and name works some times. This issue is happening randomly.
I don't think this issue is because of the files size or so. Because it works for the same file when we try again later.

Thank you
Achyuth
 
Don't get me started about those stupid light bulbs.
 
subject: problem retrieving a zip file from FTP server using org.apache.commons.net.ftp.