I am getting “Java heap space Error” while running the reports in tomcat.
I am using the virtualizer with the JRXMLDataSource.
I am getting results/records in XML format. In that XML file it contains
nearly 9000 records. While displaying those details HTML format, I am
getting this heap space error.

JRDataSource ds = new JRXmlDataSource(new BufferedInputStream(new
FileInputStream(getReportOutputDir()  + System.getProperty("file.separator")
+ "JobView.xml")), "/job.report");
File fTemp = new File(getReportOutputDir() +
System.getProperty("file.separator") + "tmp");
if (!fTemp.exists()) {
      fTemp.mkdirs();
}
JRSwapFile swapFile = new JRSwapFile(fTemp.toString(), 1024, 1024);
JRSwapFileVirtualizer virtualizer = new JRSwapFileVirtualizer(2, swapFile,
true);
// filling the report
JasperPrint jasperPrint = fillReport(getOutputDir() + "reports" +
System.getProperty("file.separator")
+ "JobView.jasper", ds, virtualizer);
JasperExportManager.exportReportToHtmlFile(jasperPrint, getReportOutputDir()
+ System.getProperty("file.separator") +  "JobView.html");
if (virtualizer != null) {
        virtualizer.cleanup();
}
-----

private JasperPrint fillReport(String fileName, JRDataSource dataSource,
 JRSwapFileVirtualizer virtualizer) throws JRException {

 long start = System.currentTimeMillis();
  // Preparing parameters
  Map < Object, Object > params = new HashMap < Object, Object > ();
  params.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
  Document document = JRXmlUtils.parse(new File(getReportOutputDir()
  + System.getProperty("file.separator") + "JobView.xml"));
   params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT,
document);
   params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
   params.put(JRParameter.REPORT_LOCALE, getLocale());
   params.put("BaseDir", getOutputDir() + "reports");
  JasperPrint jasperPrint = JasperFillManager.fillReport(fileName, params,
dataSource);
  virtualizer.setReadOnly(true);
  System.err.println("Filling time : " + (System.currentTimeMillis() -
start));
   return jasperPrint;
}

I have increased the heap memory, but some times it is executing,but it is
taking 5 to 6 minutes.
Some times it giving heap memory size error. Please correct me if i have
done in wrong way.

Here,JobView.xml file is having data, I have to records from that file and
display those records in HTML format.

Please help me

Thanks,
Satya
                        

 





-- 
View this message in context: 
http://www.nabble.com/JRFileVirtualizer-for-the-XMLDatasource-tf3914644.html#a11099328
Sent from the jasperreports-questions mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions

Reply via email to