[SOLVED][JasperReports Server] Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space

Hello to you all ,

I started in the world of reporting. Here is my problem :

I created a report in iReport . The preview of the report in iReport is going very well , and I can export the results of my report in XLS format without worries. The generated report contains 422 pages ( a little over 10,000 lines of results) 9 columns.

When I upload the same report on my JasperServer Report and executes server, everything is going very well . By cons when exporting to XLS , I always error
 

An internal server error has occurred. Please contact your system administrator.
 
Details : Handler processing failed ; nested exception is java.lang.OutOfMemoryError : Java heap space

I was fine read, Googled right and left in search of a solution , I can not find anything that solves my problem. But I have a good server core i5 , 16 GB of RAM ... So I do not think short side RAM. I think it's a bad configuration or I have read the solution without the skills to apply it.

I want to say that in other reports, is promptly executed and exports correctenet . My server works perfectly fine otherwise .

Tell me what you need to help me see more clearly and solve my problem :)

Thank you in advance .

JonReport's picture
111
Joined: Aug 13 2013 - 5:25am
Last seen: 7 years 12 months ago

7 Answers:

Hello JonReport,

- check your JVM startup parameters
sudo service tomcat7 status # to find out your pid
sudo jmap -J-d64 -heap pid # -J-d64 for a 64-bit System, to print info about heap memory

- try to understand environment variables in ubuntu

- take a look at the differences between JAVA_OPTS and CATALINA_OPTS

- decide how to change the JAVA_OPTS(there are some ways)
I do it in /etc/default/tomcat7, e.g.:

JAVA_OPTS="-Djava.awt.headless=true -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Xss2m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"

then restart tomcat

...and it works now :)

Marius
 

mariuss's picture
178
Joined: Aug 11 2013 - 2:33pm
Last seen: 9 years 2 months ago

You, mariuss, make my day !

Your post is just what I needed! Documentation with simple but precise references and a concrete example !

My problem is now fully resolved :).

____________________________________________

For people in the same configuration as me :

Here is my current JAVA :

java -version

java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

My JasperServer Reports Server is installed on a Ubuntu 12.04 LTS server through a .WAR compiled by me according to the documentation and executed by a Tomcat 6 Server.

In order to increase the JVM memory. I did an
ps -aux | grep java

which allowed me to see that my JVM was configured with a-Xmx128m.

To change the JAVA_OPTS (there are some ways), e.g.:
nano /etc/default/tomcat6
OR (depend of your tomcat version)
nano /etc/default/tomcat7

then add , e.g.:
JAVA_OPTS="-Djava.awt.headless=true -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Xss2m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"

Then restart tomcat, ... and it works now :) !

JonReport - 9 years 4 months ago

Hello. I am having similar issue with Jasper Report Server - java.lang.OutOfMemoryError: Java heap space. This is making the application completely unresponsive.

The issue occurs at multiple locations and logs provided below. I have set the JVM Heap space to 8GB, but still does not help. Please let me know if you have any solutions. Thanks in advance.

java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:263)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:106)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:116)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:203)
at java.io.Writer.write(Writer.java:140)
at net.sf.jasperreports.engine.export.JRHtmlExporter.exportText(JRHtmlExporter.java:1224)
at net.sf.jasperreports.engine.export.JRHtmlExporter.exportGrid(JRHtmlExporter.java:815)
at net.sf.jasperreports.engine.export.JRHtmlExporter.exportPage(JRHtmlExporter.java:730)
at net.sf.jasperreports.engine.export.JRHtmlExporter.exportReportToWriter(JRHtmlExporter.java:679)
at net.sf.jasperreports.engine.export.JRHtmlExporter.exportReport(JRHtmlExporter.java:389)

JBWEB000236: Servlet.service() for servlet STVPdfServlet threw exception: java.lang.OutOfMemoryError
    at java.io.ByteArrayOutputStream.hugeCapacity(ByteArrayOutputStream.java:123) [rt.jar:1.7.0_201]
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:117) [rt.jar:1.7.0_201]
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) [rt.jar:1.7.0_201]
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153) [rt.jar:1.7.0_201]
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) [rt.jar:1.7.0_201]

ashwinlunkad - 4 years 3 weeks ago

Have you tried increasing the memory allocated to your JVM on your serer? The settings you should check are -Xms and -Xmx.

nicolaifriis's picture
Joined: May 25 2010 - 4:32am
Last seen: 7 years 6 months ago
Try this
 
You can use a virtualizer to limit the use of memory (Tools->Options->iReport->Compilation and execution (tab) ->Execution options (tab)  check "Use virtualizer". The vitualizer can be configured in the tab  "Virtualizer".
 
If the error happens at export time, the virtualizer is not useful, and you have to increase the heap size (meaning set a bigger value for the option -J-Xmx512m change 512 to 1000 or more..may be it will help..
try it..
 
hishamkmr's picture
810
Joined: Sep 4 2013 - 5:07am
Last seen: 8 years 11 months ago

For a more comprehensive treatment of performance, take a look at our Wiki's JasperReports Server Performance Reference.

It will explain how to configure the JVM as well as other performance tips.

djohnson53's picture
162762
Joined: May 25 2012 - 11:10am
Last seen: 1 year 1 month ago

Wow, so many answers! It's just great!

My JasperServer Reports Server is installed on a Ubuntu 12.04 LTS server through a .WAR compiled by me according to the documentation and executed by a Tomcat 6 Server.

In order to increase the JVM memory. I did an
ps -aux | grep java

which allowed me to see that my JVM was configured with a-Xmx128m. However I have not found how increase it. What is the magic command line ?

I tried this :
export set JAVA_OPTS="-Xms128m -Xmx512m"

Then restart :
service tomcat6 restart

But when I check with an
ps -aux | grep java

Nothing has changed I'm still-Xmx128m. I think I am doing wrong to apply the settings and check.

The solution to virtualize am also interested, but I would like to have a detailed step by step guide to setup it. It sounds complex but sustainable me.

 

JonReport's picture
111
Joined: Aug 13 2013 - 5:25am
Last seen: 7 years 12 months ago

If you're using the Ubuntu tomcat6 service try adding the -Xmx argument in /etc/default/tomcat6 (JAVA_OPTS variable).

lucianc - 9 years 5 months ago

Hello,

I am now almost certain that the configuration of JVM is the solution to my problem. I just really stuck on this step. I can not really passing the parameters -Xms and -Xmx to JVM.

Here is my current JAVA :

java -version

java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

JonReport's picture
111
Joined: Aug 13 2013 - 5:25am
Last seen: 7 years 12 months ago

Not finding how to change settings of JVM. I performed a clean install by uninstalling and re-installing completely JasperReport Server and Tomcat.

Now I have no more problems, so I did not do anything special from my point of view in terms of configuration. But I would still like to know for the future and my general knowledge how to change settings of JVM. If a kind soul going around, I'm interested.

My question is resolved in the sense that I have no more problems.

Thank you very much to those who took the time to look at my problem.

JonReport's picture
111
Joined: Aug 13 2013 - 5:25am
Last seen: 7 years 12 months ago

added as answer :)

mariuss - 9 years 5 months ago

i can't figure out what is happening through but i have got this error. help plz...........................................

ullu - 7 years 8 months ago
Feedback
randomness