Jump to content
Changes to the Jaspersoft community edition download ×

Help with XML Datasource for subreport


feliciayong

Recommended Posts

I'm using iReport 1.2.8 for this scenario.

===

Attached are 3 files used:

1) addrBook.jrxml (main report)

2) addrBookEmail.jrxml (subreport)

3) addy.xml

===

Connections properties are as follows:

Name: addressBookDS

Type of connection / datasource: XML file datasource

XML file: [somepath]addy.xml

Create datasource using this expression: /addressbook/category/person

===

I have a main report with the following fields:

FIELD NAME DESCRIPTION TYPE

ID @id Integer

LASTNAME lastname String

FIRSTNAME forname String

CATEGORY ancestor::category/@name String

===

I have one subreport email addresses.

This subreport element has "((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/person/email")" as connection expression (of type datasource expression) and as subreport expression "/addrBookEmail.jasper" of type String.

===

In addrBookEmail.jasper I have defined only one field:

Field Name Field Description Type

EMAIL .(i.e. a dot here) java.lang.String

===

I encountered the following compilation errors when I try to compile the main report:

ErrorÂfillingÂprint... ErrorÂevaluatingÂexpressionÂ:Â ÂÂÂÂSourceÂtextÂ:Â((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/addressbook/category/person/email")

java.lang.ClassCastException ÂÂÂÂatÂaddrBook_1164359667180_333532.evaluate(addrBook_1164359667180_333532.java:201) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:186) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:537) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:505) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:805) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:327) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:400) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:732) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:660) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517) ÂÂÂÂatÂit.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:726) ÂÂÂÂatÂjava.lang.Thread.run(Thread.java:534) NESTEDÂBYÂ: java.lang.ClassCastException ÂÂÂÂatÂaddrBook_1164359667180_333532.evaluate(addrBook_1164359667180_333532.java:201) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:186) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:537) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:505) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:805) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:327) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:400) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:732) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:660) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517) ÂÂÂÂatÂit.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:726) ÂÂÂÂatÂjava.lang.Thread.run(Thread.java:534) NESTEDÂBYÂ: net.sf.jasperreports.engine.fill.JRExpressionEvalException:ÂErrorÂevaluatingÂexpressionÂ: ÂÂÂÂSourceÂtextÂ:Â((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/addressbook/category/person/email") ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:197) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:537) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:505) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:805) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:327) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:400) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:732) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:660) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517) ÂÂÂÂatÂit.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:726) ÂÂÂÂatÂjava.lang.Thread.run(Thread.java:534) CausedÂby:Âjava.lang.ClassCastException ÂÂÂÂatÂaddrBook_1164359667180_333532.evaluate(addrBook_1164359667180_333532.java:201) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:186) ÂÂÂÂ...Â17ÂmoreÂ

PrintÂnotÂfilled.ÂTryÂtoÂuseÂanÂEmptyDataSource...!

===

Does anyone know what should be used for the subreport datasource connection? Attached is the jrxml sources. Pls help, thanks. [file name=xmlDataSourceSubreport.zip size=2976]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/xmlDataSourceSubreport.zip[/file]

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I have solved the problem by replacing:

wrong one: "((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/person/email")" as connection expression (of type datasource expression)

with

correct one: "((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{subreport_project_ds}).subDataSource("/person/email")"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...