Jump to content
Changes to the Jaspersoft community edition download ×

Why does JR leave masses of threads in my Tomcat based webapp?


stanb123

Recommended Posts

Hi :-),

 

Recently I've been working on a reporting tool for our customers that should let them monitor their equipment from a distance. I had a bit of trouble getting going at first, but JasperReports has proven to be an excellent tool. After getting all of the scriptlets and chart customizers right it's been a pleasure to work with. There's only one little hurdle I still need to pass before we can actually move our application to production.

 

The program is run from Tomcat and uses a JasperRunManager for the generation of PDF files. Which are being sent to the user using a servlet. Here's a small snippet of the report generation itsself.

 


private byte[] generateReport(int format, String reportPath, Map params, Connection conn)
throws JRException {

byte[] result;

if (format == FORMAT_CSV) {
ByteOutputStream boStream = new ByteOutputStream();
JasperPrint print = JasperFillManager.fillReport(reportPath, params, conn);

JRCsvExporter exporter = new JRCsvExporter();
exporter.setParameter(JRCsvExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRCsvExporterParameter.OUTPUT_STREAM, boStream);
exporter.setParameter(JRCsvExporterParameter.RECORD_DELIMITER, CSV_LINE_SEPARATOR);
exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, CSV_FIELD_SEPARATOR);
exporter.setParameter(JRCsvExporterParameter.IGNORE_PAGE_MARGINS, true);
exporter.exportReport();

result = boStream.getBytes();
}
else {
result = JasperRunManager.runReportToPdf(reportPath, params, conn);
}

return result;
}
[/code]
 

As you can see it is nothing spectacular. The byte array that is generated is sent to the user over the HTTP response object's OutputStream, after setting the required HTTP headers.

 

However, Tomcat warns me that there are a lot of Threads that JasperReports leaves hanging. The more reports I try to generate, the more warnings I get on closing the application. Here's a bit of the log file.

 

SEVERE: The web application [] appears to have started a thread named [AWT-Windows] but has failed to stop it. This is very likely to create a memory leak.

25-sep-2013 9:53:46 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

SEVERE: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@ab436d]) and a value of type [java.lang.Class] (value [class counter_actions_cumul_1380034442009_432466]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 

25-sep-2013 9:53:46 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

SEVERE: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1d7d58f]) and a value of type [net.sf.jasperreports.engine.export.legacy.BorderOffset$1] (value [net.sf.jasperreports.engine.export.legacy.BorderOffset$1@105a248]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 

25-sep-2013 9:53:46 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

SEVERE: The web application [] created a ThreadLocal with key of type [net.sf.jasperreports.engine.fonts.FontUtil$1] (value [net.sf.jasperreports.engine.fonts.FontUtil$1@e133da]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 

25-sep-2013 9:53:46 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

SEVERE: The web application [] created a ThreadLocal with key of type [net.sf.jasperreports.engine.fonts.FontUtil$1] (value [net.sf.jasperreports.engine.fonts.FontUtil$1@e133da]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 

25-sep-2013 9:53:46 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

SEVERE: The web application [] created a ThreadLocal with key of type [net.sf.jasperreports.engine.fonts.FontUtil$1] (value [net.sf.jasperreports.engine.fonts.FontUtil$1@e133da]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 

25-sep-2013 9:53:46 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

SEVERE: The web application [] created a ThreadLocal with key of type [net.sf.jasperreports.engine.fonts.FontUtil$1] (value [net.sf.jasperreports.engine.fonts.FontUtil$1@e133da]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

 

This brings me to my question:

*) Does this matter very much?

*) Is it dangerous? Does it have the potential to eventually bring my Tomcat server down because of memory issues?

*) Is it related to my reports? I see a lot of FontUtil warnings, could it have to do with me using a special font?

*) What can I do to stop this from happening?

 

Used software:

*) Tomcat 7

*) JasperReports 5.1.0

*) MySQL

 

Libraries included:

*) jasperreports-5.1.0.jar

*) jcommon-1.0.15.jar

*) jfreechart-1.0.12.jar

*) commons-beanutils-1.8.0.jar

*) commons-collections-2.1.1.jar

*) commons-digester-2.1.jar

*) commons-logging-1.1.1.jar

*) groovy-all-2.0.1.jar

*) iText-2.1.7.js2.jar

*) jdt-compiler-3.1.1.jar

 

If you need any more detail, please ask, I'd be glad to expand the question a bit.

 

Thanks.

Link to comment
Share on other sites

  • 4 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...