JasperReports too slow

Hi

I'm having trouble with the speed of the report.
My datasource is an XML using XPATH.
IReport, the report is shown in less than 7 seconds and the java program it takes 8 minutes.

This delay occurs in Fill.

can anyone help?

How do I get JRXmlDataSource.class? This would make any difference?

Tks

Luciano

Code:
    public void fill() throws JRException, IOException
    {       
        HashMap<String, Object> params = new HashMap<String, Object>();               
        System.out.println("Início Fill: " + now());       
        ResourceBundle myresources = ResourceBundle.getBundle("report");
        Document docXML = JRXmlUtils.parse(new File(sXMLDataSource));
 
        params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, docXML);
        params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "yyyy-MM-dd");
        params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
        params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);       
 
        params.put("REPORT_QUADRICULADO", sImprimeQuadriculado );
        params.put("REPORT_FOLHAROSTO", sImprimeFolhaRosto );
 
        params.put(JRParameter.REPORT_RESOURCE_BUNDLE, myresources  );
        //params.put(JRParameter.REPORT_LOCALE, Locale.US);
        System.out.println("Rodar2 Fill: " + now());
        //JasperFillManager.fillReportToFile(sFileJasper, sFilePrint, params);
        oFilePrint = JasperFillManager.fillReport(sFileJasper, params);   
 
        System.out.println("Fim Fill: " + now());
    }
</td></tr></tbody></table>
lucianocasa's picture
Joined: Jun 11 2010 - 7:47am
Last seen: 13 years 1 day ago

7 Answers:

have you tried using JaxenXPathExecuterFactory?

I have seen somewhere (probably here in forums), this implementation is a lot faster than the default one.

override the property in jasperreports.properties file

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

ceday's picture
491
Joined: Nov 10 2010 - 5:55am
Last seen: 8 years 6 months ago

I did not try I'll try to see if it changes anything.
I'll see how I do this in eclipse because I do not know.
Tks

lucianocasa's picture
Joined: Jun 11 2010 - 7:47am
Last seen: 13 years 1 day ago

Sensational and unbelievable!!
The report went on to run in 7 seconds.
Tks a lot

lucianocasa's picture
Joined: Jun 11 2010 - 7:47am
Last seen: 13 years 1 day ago

Hi,

Can you please post the code that you used in order to make it work? I've been trying to add the following

DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance();
JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory",
    "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory");

But nothing is changing (even if I put "bla bla bla" instead of "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory")

here's the code I'm using

private JasperPrint getJasperPrintInstance(JasperReport report) throws JRException, NamingException, SQLException {
    JasperPrint jasperPrint = null;
    DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance();
    JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory", "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory");
    if (dataSource == null) {
        jasperPrint = JasperFillManager.fillReport(report, this.reportParams, connection);
    } else {
        jasperPrint = JasperFillManager.fillReport(report, this.reportParams, new JRBeanCollectionDataSource(getDataSource()));
    }
    return jasperPrint;
}

mazen.doha's picture
Joined: Sep 3 2015 - 8:23am
Last seen: 4 years 6 months ago

Mazen, did you get it to work? If so, how? I am having the same exact behavior. 

Thanks for your time.

javier.ggi90's picture
Joined: Dec 6 2015 - 1:46pm
Last seen: 6 years 1 month ago

Solved it using jasperreports-6.3.1 and adding the following code (supposed to be deprecated according to a post I saw before):

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

javier.ggi90's picture
Joined: Dec 6 2015 - 1:46pm
Last seen: 6 years 1 month ago

javier can you post the code you used?

 

Thanks

mazen.doha's picture
Joined: Sep 3 2015 - 8:23am
Last seen: 4 years 6 months ago
Feedback
randomness