Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileNotFoundException

 
Jaykiran Teraiya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone..

I have following code inside my method.


When I execute my webapplication, I am getting below error message.


I made sure that I've write access to the tomcat directory.

Any help would be appreciated.

Thanks
Jay
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well champ, it appears to be a permission problem. Please try to write your file to another directory (such as C:\Jaykiran), just to make sure it isn't a permission problem.
 
Jaykiran Teraiya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roberto,

I guess that was the problem. Thanks for the solution. I've given my home directory path to resolve this, but the problem is what path should I give when I deploy the application to production server? We are using apache tomcat 6 in production.

Thanks
Jay

 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make a directory for the use of this application and save the files there. It's up to you to choose a suitable place on the server.

(By the way, do you really need to write files to disk from Tomcat? Why?)
 
Jaykiran Teraiya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to generate a very large excel file from the database result set. I am using apache poi XSSF api. It has very high memory foot print so I was running into java heap space exception. I found one solution BigGrid Demo. I am doing proof of concept with my large data set, ultimately I have to write the entire thing to ServletOutputStream, so that user can download it directly.

But it seems that as file size is growing, data is getting corrupted and even this solution does not seem to work

do you have any idea about this kind of issue and it's probable solution.

Thanks
Jay
 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Half of the solution is to write the document directly to the servlet's output stream, instead of writing it to a file and then copying that file to the output stream. (By the way, the File class has methods which make it unnecessary for you to choose a directory where temp files will be stored.)

However, as you are finding, the other half of the problem is to make sure your document isn't so large that it causes Tomcat to run out of memory. This has nothing to do with I/O or streams at all. You can give Tomcat more memory, up to a point, but once your documents get too large for that you are out of luck. You would have to produce multiple smaller documents, or something like that.
 
Jaykiran Teraiya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thanks for the reply. I'll try to remove the intermediate file steps and write directly to the servletoutputstream. Let's see how does that work.

Thanks
Jay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic