简体   繁体   English

JasperReports:fillReport非常慢

[英]JasperReports: fillReport very slow

We have this code to generate a PDF report, from XML input. 我们有这段代码可以根据XML输入生成PDF报告。 It is very slow (2 hours to process 280K rows; 10 minutes for 70K rows, on a Solaris T5220). 这非常慢(在Solaris T5220上,处理280K行需要2个小时; 70K行需要10分钟)。

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. 正如您所看到的,此DOES包括“ use Jaxen”属性-但是使用Jaxen和不使用Jaxen的性能没有发现差异。 Therefore either the "use Jaxen" configuration that we have is incorrect, or we have a different issue. 因此,我们拥有的“使用Jaxen”配置不正确,或者存在其他问题。

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. -我已经打开了日志记录,但是日志记录不是很详细,除非涉及到逐行详细记录日志的内容-没有任何内容说“我已经看过'use Jaxen'指令并将使用Jaxen”或遵循这些原则的任何事情。

Very much appreciated! 非常感谢!

Update: When I run this on my laptop (a Windows 7 system), the 280K report runs in 16 minutes; 更新:当我在笔记本电脑(Windows 7系统)上运行此程序时,280K报告将在16分钟内运行; 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; 当我在笔记本电脑上使用Xalan而不是Jaxen运行相同的报告时,我是从08:00开始的,现在是15:00,但尚未完成; therefore the Jaxen library is what I need. 因此Jaxen库是我所需要的。

What I do not understand is why there is absolutely no difference when running on Solaris 10, on a T5220. 我不明白的是,为什么在T5220的Solaris 10上运行时绝对没有区别。 I will dig into the RAM and so forth - perhaps there is a resource constraint. 我将深入研究RAM等-可能存在资源限制。 I would still appreciate any suggestions if anybody has encountered this. 如果有人遇到此问题,我仍将不胜感激。

I've the same problem. 我有同样的问题。 a xml of 330ko (2k rows), takes 9 800ms, and if I use Jaxen it takes41 000 ms. 一个330ko(2k行)的xml,需要9 800ms,如果我使用Jaxen,则需要41000 ms。 So I wonder if the current version JR 5.6.1 is already figer this issue. 所以我想知道当前版本的JR 5.6.1是否已经解决了这个问题。 but If I runs q xml wtih 11 114ko (65536 rows), it takes 1.7hours! 但是如果我以11 114ko(65536行)运行q xml,则需要1.7小时! the DOM runs too slowly and takes a lot the memory. DOM运行太慢并且占用大量内存。 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/ SAX: http//blog.synyx.de/2012/08/big-jasper-reports-with-custom-xml-datasource/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM