The moose likes Websphere and the fly likes OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "OutOfMemoryError" Watch "OutOfMemoryError" New topic


sunil kumbs

Joined: Dec 30, 2008
Posts: 16
Hi All,

I've an application where I generate a report and export it to excel. The list is quite huge and contains more than 8000 records. But while generating the report I'm getting the below mentioned error. Can anybody please help me with this.

Uncaught exception thrown in one of the service methods of the servlet: Exception thrown : java.lang.OutOfMemoryError
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:203)
at java.util.zip.ZipFile.<init>(ZipFile.java:234)
at com.ibm.ws.classloader.SinglePathClassProvider$2.run(SinglePathClassProvider.java:242)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
at com.ibm.ws.classloader.SinglePathClassProvider.getClassBytesFromJar(SinglePathClassProvider.java:233)
at com.ibm.ws.classloader.SinglePathClassProvider.getClassBytes(SinglePathClassProvider.java:178)
at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java:457)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:389)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Note: My server heap size is, Initial: 128mb Maximum: 512mb, WAS version , SunOS, version 5.9, Java version = 1.5.0_13

Is there any other alternative than increasing the heap size?

Thanks in advance

Many of life's failures are people who did not realize how close they were to success when they gave up. -- Thomas A. Edison
Vicki Amin
Ranch Hand

Joined: Aug 31, 2005
Posts: 32

How are you exporting it to Excel? One of the workarounds would be (in case your excel is not too complicated) be to write the data to the file system in a CSV format and then push it using a servlet to the browser with application/vnd.ms-excel as the MIME type. This way you would not be utilizing a lot of heap memory. In case the excel size is huge; you could consider zipping it up before you push it to the browser.

SCJP 1.4 | SCWCD 1.3 | SCBCD 1.4 | Oracle 9i:SQL | TOGAF 9
sunil kumbs

Joined: Dec 30, 2008
Posts: 16
Hi Vicki,

From the error stack trace I've posted above you can see i'm trying to zip it before pushing it to browser, and thats when I get this OutofMemory error.
Vicki Amin
Ranch Hand

Joined: Aug 31, 2005
Posts: 32

I didn't realize that you were facing errors during the zipping process since you mentioned in your post that you get the error while generating the report.

I have used this snippet of code earlier in projects where we have zipped up decent sized excel files (data represented as objects) - upto 30 megs with a max heap size set to 512 megs. Is this something similiar that you have on your end?

Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

sunil kumbs wrote:From the error stack trace I've posted above you can see i'm trying to zip it before pushing it to browser...

Actually that stack trace shows you are trying to load a class, presumably from a jar file. Lines from the stack trace like this one:

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

tell me that. However your technique for "zipping it before pushing it to browser" is using more memory than necessary. Don't write the entire zipped data to a byte array, just wrap the GZIPOutputStream around the servlet response's output stream and write to that. And what's the ObjectOutputStream for?
I agree. Here's the link: http://aspose.com/file-tools
subject: OutOfMemoryError
Similar Threads
Extracting Images from the image jar file
ant build error
tomcat ZipException when starting up
creating java file