HTML problems within a Multi-threaded Java application

We have built a multi-threaded Java application that is using Jasper templates to build PDFs. For the most part, it works fine, but we are presented with a problem when we try to include HTML in the PDF, in a multi-threaded setup. 

Problem description

Java application started ->

1) Load in Fonts, Resources, etc

2) Spawn a set of threads determined by application parameters

        -> Thread N

             1) Fetch data from 3rd party systems

             2) Fetch HTML data from the database

             3) Construct an XML using this data, to be used as the data source

             4) Pass the XML to the .jasper template file and create a PDF report using all of the above. Exact method call in java: JasperFillManager.fillReport("template.jasper", parameters);

The problem we have noticed, is that once every 100 or so reports, there are random formatting changes introduced in the HTML that weren't there in the core HTML. For instance, a small subsection of the text will be rendered as bold, or some text will be of a larger font size, or the left column of a table will overlap the right column. Etc. This only happens within the HTML objects on the templates, the Jasper objects are able to take text inputs provided to it and render correctly each time. And as far as we know, it only occurs when we are running more than one thread - with the increase in the number of threads resulting in a higher probability of a formatting error being included in the pdf. It is however random. It's also worth noting that we are using the HTML component that's bundled with Jasper.

Solution tried

One of the first things we tried was to check if there is a problem with XML creation, and thus compared the XMLs of problem and non-problem reports and they were the same. So it would appear this problem is happening at the time of report creation using Jasper jars. Which points to a potential problem within the Jasper library itself? Or perhaps we aren't setting some configuration settings properly? 

Jars used by the application to build these reports:








Any help, pointers, suggestions will be greatly appreciated. We have tried everything we could before reaching out to the Jasper community and nothing has worked so far. 

umair.hl's picture
Joined: Nov 8 2016 - 2:52am
Last seen: 5 years 11 months ago

Ideas anyone?

umair.hl - 6 years 4 months ago

0 Answers:

No answers yet