Reputation: 21
We have this code to generate a PDF report, from XML input. It is very slow (2 hours to process 280K rows; 10 minutes for 70K rows, on a Solaris T5220).
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
FileInputStream fileStream = new FileInputStream(rawXmlFile);
ds = docBuilder.parse(fileStream);
Map<String, Object> params = new HashMap<String, Object>();
params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, ds);
params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, com.vodafone.gdsp.reporting.enums.xml.DateFormat.DATE_FORMAT_ISO8601);
params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "##0.##");
params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
params.put(JRParameter.REPORT_LOCALE, Locale.UK);
params.put("REPORT_DIR", jasperFile.substring(0, jasperFile.lastIndexOf("/")));
try {
virtPageSize = Integer.parseInt(reportConfig.getJasperVirtPageSize());
virtPageDir = reportConfig.getJasperVirtPageDir();
} catch (NullPointerException npe) {
logger.info("Virtual page size and directory not assigned, using the default value of virtPageSize {} and virtPageDir {}", virtPageSize, virtPageDir);
} catch (Exception ex) {
logger.error("Exception while fetching virtual page size and directory {}", ex.getMessage());
}
logger.info("Using Jasper virtual parameters ({}, {})", virtPageSize, virtPageDir);
JRFileVirtualizer virtualizer = new JRFileVirtualizer(virtPageSize, virtPageDir);
JRVirtualizationHelper.setThreadVirtualizer(virtualizer);
params.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance();
JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory",
"net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory");
File jasperReport = new File(jasperFile);
JasperPrint jasperPrint = JasperFillManager.fillReport(new FileInputStream(jasperReport), params);
This DOES include the "use Jaxen" property as you can see - but there is no difference observed in the performance with Jaxen, and without Jaxen. Therefore either the "use Jaxen" configuration that we have is incorrect, or we have a different issue.
Has anybody else encountered this and solved it? Has anybody got any suggestions for how to determine the problem? - I have turned up logging, but the logging is not very detailed, except when it comes to logging stuff at the detailed line-by-line level - nothing says "I have seen the 'use Jaxen' directive and will use Jaxen" or anything along those lines.
Very much appreciated!
Update: When I run this on my laptop (a Windows 7 system), the 280K report runs in 16 minutes; when I run the same report with Xalan instead of Jaxen on my laptop, well I started it at 08:00, and it is now 15:00, and it has not completed; therefore the Jaxen library is what I need.
What I do not understand is why there is absolutely no difference when running on Solaris 10, on a T5220. I will dig into the RAM and so forth - perhaps there is a resource constraint. I would still appreciate any suggestions if anybody has encountered this.
Upvotes: 2
Views: 2845
Reputation: 11
I've the same problem. a xml of 330ko (2k rows), takes 9 800ms, and if I use Jaxen it takes41 000 ms. So I wonder if the current version JR 5.6.1 is already figer this issue. but If I runs q xml wtih 11 114ko (65536 rows), it takes 1.7hours! the DOM runs too slowly and takes a lot the memory. So I think may be it should be changed to another method of parsing. SAX: http://blog.synyx.de/2012/08/big-jasper-reports-with-custom-xml-datasource/
Upvotes: 1