Producing report with subreport containing a list in java applet with XML datasource

0

Hi all,

I am attempting to produce a report in a java applet which contains a subreport. The subreport contains a list component and several columns of data. Currently, the report works perfectly in iReport 4.1.3. The subreport uses connection type 'Don't pass data' and instead I pass the 'XML_DATA_DOCUMENT' parameter to the subreport.

I cannot get this to work in the app, however. Inside the applet, when a preview report button is pressed, a method is called which loads in the already compiled jasper template and populates the report using the line:

JasperFillManager.fillReport(jasperReport, map, jrXmlDataSource);

This works fine for reports without subreports, however for the report with a subreport I get the following error:

Aug 16, 2017 2:48:53 PM net.sf.jasperreports.engine.query.JRXPathQueryExecuter <init>
WARNING: The supplied org.w3c.dom.Document object is null.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at net.sf.jasperreports.engine.fill.JRPrintBand.addOffsetElements(JRPrintBand.java:101)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.addSubElements(JRFillElementContainer.java:623)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.fillElements(JRFillElementContainer.java:600)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:406)
    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 com.pst.alpaca.reports.AlpacaReport.generateJasperReports(AlpacaReport.java:978)
    at com.pst.alpaca.reports.AlpacaReport.previewReport(AlpacaReport.java:465)
    at com.pst.alpaca.reports.AlpacaReport$3.actionPerformed(AlpacaReport.java:192)
    at com.everest.oscar.gui.MouseOverButton.fireClickAction(MouseOverButton.java:139)
    at com.everest.oscar.gui.MouseOverButton.mouseReleased(MouseOverButton.java:106)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    at java.awt.Component.processMouseEvent(Component.java:6533)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

After some digging around online I found the following thread on Stack Overflow: https://stackoverflow.com/questions/9785451/generate-jasper-report-with-...

I then implemented a similar solution to this:

try {
                    GeneralResource subReportRes = new GeneralResource(PreparedOpeningReport.class.getResource("prepared_opening_sub_report.jasper"));
                    JasperReport jasperSubreport = (JasperReport) JRLoader.loadObject(subReportRes.getInputStream());
                    map.put("subreportParameter", jasperSubreport);
                } catch (IOException e) {
                    e.printStackTrace();
                }

And within iReport I set the subreport parameter expression to $P{subreportParameter}. This gave me the following error message:

Error evaluating expression : Source text : $P{subreportParameter}

net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203)
net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:876)
net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:284)
net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:347)
net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:275)
net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)
net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:473)
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2021)
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755)
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:265)
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:765)
net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
com.pst.alpaca.reports.AlpacaReport.generateJasperReports(AlpacaReport.java:978)
com.pst.alpaca.reports.AlpacaReport.previewReport(AlpacaReport.java:465)
com.pst.alpaca.reports.AlpacaReport$3.actionPerformed(AlpacaReport.java:192)
com.everest.oscar.gui.MouseOverButton.fireClickAction(MouseOverButton.java:139)
com.everest.oscar.gui.MouseOverButton.mouseReleased(MouseOverButton.java:106)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
java.awt.Component.processMouseEvent(Component.java:6533)
javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
java.awt.Component.processEvent(Component.java:6298)
java.awt.Container.processEvent(Container.java:2236)
java.awt.Component.dispatchEventImpl(Component.java:4889)
java.awt.Container.dispatchEventImpl(Container.java:2294)
java.awt.Component.dispatchEvent(Component.java:4711)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
java.awt.Container.dispatchEventImpl(Container.java:2280)
java.awt.Window.dispatchEventImpl(Window.java:2746)
java.awt.Component.dispatchEvent(Component.java:4711)
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
java.awt.EventQueue.access$500(EventQueue.java:97)
java.awt.EventQueue$3.run(EventQueue.java:709)
java.awt.EventQueue$3.run(EventQueue.java:703)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
java.awt.EventQueue$4.run(EventQueue.java:731)
java.awt.EventQueue$4.run(EventQueue.java:729)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Any help with this would be much appreciated. I just can't seem to get the main report to read in the subreport in the java app.

Thanks.

michael.harrison's picture
Joined: Aug 16 2017 - 6:28am
Last seen: 3 years 6 months ago

0 Answers:

No answers yet
Feedback