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

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: 9 years 4 months ago

1 Answer:

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: 7 hours 17 min ago
Feedback
randomness