compiler error when language="java" and datasource is xmldatasource

0

log4j:WARN No appenders could be found for logger (net.sf.jasperreports.engine.xml.JRXmlDigesterFactory).
log4j:WARN Please initialize the log4j system properly.
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method subDataSource(String) is undefined for the type JRDataSource
                value = ((net.sf.jasperreports.engine.JRDataSource)parameter_REPORT_DATA_SOURCE.getValue()).subDataSource("/measInfo/measValue"); //$JR_EXPR_ID=9$
                                                                                                            <----------->
2. The method subDataSource(String) is undefined for the type JRDataSource
                value = ((net.sf.jasperreports.engine.JRDataSource)parameter_REPORT_DATA_SOURCE.getValue()).subDataSource("/measInfo/measValue"); //$JR_EXPR_ID=9$
                                                                                                            <----------->
3. The method subDataSource(String) is undefined for the type JRDataSource
                value = ((net.sf.jasperreports.engine.JRDataSource)parameter_REPORT_DATA_SOURCE.getValue()).subDataSource("/measInfo/measValue"); //$JR_EXPR_ID=9$
                                                                                                            <----------->
3 errors

    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:204)
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:241)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:501)
    at DummyReport.main(DummyReport.java:28)
 

 

PFA JRXML file

Attachments: 
abhibhagia's picture
Joined: Jun 27 2013 - 8:24pm
Last seen: 5 years 11 months ago

1 Answer:

1

You have to type cast the datasource explicitely:

((...JRXmlDataSource) $P{REPORT_DATA_SOURCE}).subDataSource...

Cheers, Thomas

http://www.thomaszimmer.net

Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 5 days 12 hours ago
Feedback
randomness