Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
esha sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still waiting for answer...
 
Joe Ess
Bartender
Posts: 9279
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
esha sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9279
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no limitation on the size of a file. Can you show us your code?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
esha sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
************************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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Bernie Barnard
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 275
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Achyuth Nambiar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic