• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't download large file from url by tomcat

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all..

I have a problem that's been bothering me for a month already.

I write a code that download url file to my workspace. My code works well for any size file.
Here is my code:



But, i want to do it automaticly, so i packaged this code by Java Service. I use tomcat 7.0.12.

Now, this code works well only for small files. If i try to download large file like the second one, I get this error for "byteCount = in.read(buffer);" line:


java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:185)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
at sun.net.ftp.impl.FtpClient.readServerResponse(FtpClient.java:417)
at sun.net.ftp.impl.FtpClient.readReply(FtpClient.java:494)
at sun.net.ftp.impl.FtpClient.issueCommand(FtpClient.java:529)
at sun.net.ftp.impl.FtpClient.issueCommandCheck(FtpClient.java:540)
at sun.net.ftp.impl.FtpClient.openPassiveDataConnection(FtpClient.java:603)
at sun.net.ftp.impl.FtpClient.openDataConnection(FtpClient.java:696)
at sun.net.ftp.impl.FtpClient.getFileStream(FtpClient.java:1269)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:427)
at java.net.URL.openStream(URL.java:1035)
at MyService.downloadFilesToWorkspace(MyService.java:137)
at MyService.doDownloadForToday(MyService.java:87)
at MyService.start(MyService.java:47)
at MyService.windowsService(MyService.java:35)
java.lang.NullPointerException
at MyService.downloadFilesToWorkspace(MyService.java:153)
at MyService.doDownloadForToday(MyService.java:87)
at MyService.start(MyService.java:47)
at MyService.windowsService(MyService.java:35)



If someone has any idea why this happens and what sould i change, i would be glad to hear them.

Thanks,

Ori
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ori,

Have you got an answer?
I have exactly the same problem. I have tried different solutions but with the same result.
Goes well for small files, not for big ones.
The read() function stops until it get's connection reset after a while.

Also tried apache.commons.io.FileUtils.getURLToFile(URL ..., File ...) but with same result.

Curious, is that instead of getting an url file (http://...), I tried with the same file (downloaded by browser) already saved at my disk (file:///...). And from filesystem it works with the same code.
I suspect the problem is the connections opened.

Hope for a solution,
DnlCY
 
Ori Brill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi daniel,

Unfortunately, I did not find a solution then. It was part of my BSc's finish project and i was supposed to have it ready by the deadline.
Without a solution, I changed the project design so that the operation <file downloading> will not occur automatically by Java Servise but by the task scheduler of the operating system.

But still nice to find people who read my problems

Sorry And Tnx,

Ori
 
reply
    Bookmark Topic Watch Topic
  • New Topic