aspose file tools*
The moose likes Other Open Source Projects and the fly likes Jasper Subreport error, not sure whether what I am doing is correct. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper Subreport error, not sure whether what I am doing is correct. " Watch "Jasper Subreport error, not sure whether what I am doing is correct. " New topic
Author

Jasper Subreport error, not sure whether what I am doing is correct.

Daimon Masaru
Greenhorn

Joined: Oct 13, 2008
Posts: 5
So I am trying to create a Master report with a sub report from a different datasource.

I created a new parameter called dS2 to pass in the datasource for the subreport.

My subreport connection expression is $P{dS2}.dataSource("addressbook/person/phone")



So in my Java application this is my code

JRXmlDataSource jRXMLDataSource = new JRXmlDataSource("addressbook.xml", "/addressbook/person");
JRXmlDataSource jRXMLDataSource2 = new JRXmlDataSource("addressbook2.xml");

String fileName = "report8.jasper";
String pDFFileName = "report8.pdf";


HashMap hm = new HashMap();
hm.put("dS2", jRXMLDataSource2);
JasperPrint jasperPrint = JasperFillManager.fillReport(fileName, hm, jRXMLDataSource);

JRExporter jRExporter = new JRPdfExporter();
jRExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, pDFFileName);
jRExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
jRExporter.exportReport();

JRViewer jRViewer = new JRViewer(jasperPrint);

JFrame jFrame = new JFrame("Report 8");
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.getContentPane().add(jRViewer);
jFrame.pack();
jFrame.setVisible(true);



And I get a bunch of errors like that,

Exception in thread "main" net.sf.jasperreports.engine.JRRuntimeException: java.lang.StackOverflowError
at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:750)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:328)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:393)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:352)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2023)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:265)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:765)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:540)
at testmain.main(testmain.java:30)
Caused by: java.lang.StackOverflowError
at java.util.AbstractMap.hashCode(Unknown Source)
at java.util.HashMap$Entry.hashCode(Unknown Source)
at java.util.AbstractMap.hashCode(Unknown Source)
at java.util.HashMap$Entry.hashCode(Unknown Source)
at java.util.AbstractMap.hashCode(Unknown Source)
at java.util.HashMap$Entry.hashCode(Unknown Source)
at java.util.AbstractMap.hashCode(Unknown Source)
at java.util.HashMap$Entry.hashCode(Unknown Source)



Yeah, it just loops for a while before stopping. So I tried it again, this time using the same datasource, I deleted the parameter dS2 and changed my connection expression to $P{REPORT_DATA_SOURCE}.dataSource("addressbook/person/phone") for the subreport. It displays properly in iReport but the same error appears in Java

Can anyone tell me what I am doing wrong?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jasper Subreport error, not sure whether what I am doing is correct.