XML data source is very slow to parse

Table of Contents 

Issue

Parsing a very large XML data source in the server can be very slow. In a custom application using a 24K line XML data source to fill a report took over 24 minutes on a Mac with dual 4 core processors. On another machine it was reported to take as long as 2 hours. Yet the same data source took less than 2 minutes to fill a report when previewed in iReport Designer.

The reason is because iReport Designer uses the Jaxen XPath engine while the JasperReports Library uses the Xalan XPath engine. Jaxen is much faster.

Switching to the Jaxen XPath engine on the server reduced the time to fill the report from 24 minutes to 2 minutes.

Resolution

By default JasperReports Library uses XalanXPathExecuterFactory, see:

http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.xpath.executer.factory

Open <js-install>/webapps/jasperserver-pro/WEB-INF/classes/jasperreports.properties. Add the following property:

net.sf.jasperreports.xpath.executer.factory=net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory

In a custom application, using the JasperReports Library, use:

JRProperties.setProperty("net.sf.jasperreports.xpath.executer.factory"
                                         ,"net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory");
Feedback
randomness