I'm using the iReport 4.5.1 and I've faced a problem with connecting master report and subreport.
I have two objects:
- Account (accountID, date, listOfParagraphs) - all fields are defined in master report;
- Paragraph (account, paragraphNo, someObject) - all fields defined in subreport(stavke.jrxml).
The listOfParagraphs is defined as java.util.List<Paragraph>
(List of objects) and I want to pass it to subreport.
I've defined this subreport's properties in master report:
- Subreport expression: stavke.jasper
- Expression class: java.lang.String
- Connection type: Use a datasource expression
- Datasource expression:
new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{listOfParagraphs})
I get this error:
net.sf.jasperreports.engine.JRException: Error loading object from file : stavke.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:101)
at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:253)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:301)
.....
I've tried so hard about this, but i can't solve it.
Can someone help me, please?
@Vyccus (edited)
I've changed paths a bit:
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Documents and Settings\\D\\My Documents\\NetBeansProjects\\Project\\subreport\\"]]></defaultValueExpression>
</parameter>
and
<subreport>
<reportElement x="0" y="42" width="555" height="100"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{ls})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "stavke.jasper"]]></subreportExpression>
</subreport>
Now i get this:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at net.sf.jasperreports.engine.fill.JRFillTextField.getFormat(JRFillTextField.java:706)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:394)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:368)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2036)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:760)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:270)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:864)
at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:613)
at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:205)
at java.lang.Thread.run(Thread.java:662)