Jump to content
Changes to the Jaspersoft community edition download ×

Custom DataSource - Why exception?


kjhuebner

Recommended Posts

Hi,

I've been trying to get a master and subreport to work using a custom datasource having a hierarchical structure. (See attached .zip file for full details) The datasource is composed of a list of rows (list of Maps with fieldname,value pairs) and associated with each row is a "sub" datasource (containing list of Maps with fieldname,value pairs).

 

However, when I run report, it fails at filling the subreport due to failing at retrieving the "sub" datasource. My master template contains this snippet:

 

<subreport>

...

<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>

 

<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}.getSubDataSourceFromRow("Tasks")]]></dataSourceExpression>

...

</subreport>

 

I'm not sure how to interpret the exception--as its failing deep in the Jasper engine.

I tried explicitly casting the datasource with the classname of my custom data source, but it still fails.

 

If anyone can explain what is going on, I'd appreciate it.

Thanks!

Ken

--------------

TRACE....

 

ErrorÂfillingÂprint...

ENTEREDÂTestDataSourceFactory.getTheDatasource() ENTEREDÂTestDataSource()ÂCONSTRUCTOR ENTEREDÂaddRowÂindex=0 ENTEREDÂTestDataSource(List)ÂCONSTRUCTOR ENTEREDÂTestDataSource.putSubDataSourceFromRow()Âkey=Tasks ENTEREDÂaddRowÂindex=1 ENTEREDÂTestDataSource(List)ÂCONSTRUCTOR ENTEREDÂTestDataSource.putSubDataSourceFromRow()Âkey=Tasks java.lang.ClassCastException:Âcom.catalystwms.cct.web.beans.reports.TestDataSource ÂÂÂÂatÂTestDataSource_1154462782283_984118.evaluate(TestDataSource_1154462782283_984118:124) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:556) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:524) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:601) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:563) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:878) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:689) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:666) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) ÂÂÂÂatÂit.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:713) ÂÂÂÂatÂjava.lang.Thread.run(UnknownÂSource) NESTEDÂBYÂ: java.lang.ClassCastException:Âcom.catalystwms.cct.web.beans.reports.TestDataSource ÂÂÂÂatÂTestDataSource_1154462782283_984118.evaluate(TestDataSource_1154462782283_984118:124) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:556) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:524) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:601) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:563) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:878) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:689) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:666) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) ÂÂÂÂatÂit.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:713) ÂÂÂÂatÂjava.lang.Thread.run(UnknownÂSource) NESTEDÂBYÂ: net.sf.jasperreports.engine.fill.JRExpressionEvalException:ÂErrorÂevaluatingÂexpressionÂ:Â ÂÂÂÂSourceÂtextÂ:Â$P{REPORT_DATA_SOURCE} ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:183) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:556) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:524) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:601) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:563) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:878) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:689) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:666) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) ÂÂÂÂatÂit.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:713) ÂÂÂÂatÂjava.lang.Thread.run(UnknownÂSource) CausedÂby:Âjava.lang.ClassCastException:Âcom.catalystwms.cct.web.beans.reports.TestDataSource ÂÂÂÂatÂTestDataSource_1154462782283_984118.evaluate(TestDataSource_1154462782283_984118:124) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172) ÂÂÂÂ...Â11Âmore

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

 

 

 

 

 

[file name=TestDataSource.zip size=27835]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/TestDataSource.zip[/file] [file name=TestDataSource.zip size=27835]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/TestDataSource.zip[/file]

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

It's still failing on getting subreport's datasource (class cast exception).

 

Regarding your classpath theory, I'm already using a static classpath defined within IReport under Options | Classpath. Also, IReport finds my classes during Connection setup as it gives me an OK message.

 

1. Are there any other classpaths I have to define in IReport?

 

2. Can I assume that my custom TestDataSource IS the value contained in REPORT_DATA_SOURCE when I run the report? My reasoning is that since I have setup up a factory to return my TestDataSource using IReport's Connection setup dialog and tested OK. Whereby, when I run report within IReport shouldn't this work?

 

<subreport isUsingCache="false">

...

<dataSourceExpression><![CDATA[((com.catalystwms.cct.web.beans.reports.TestDataSource)$P{REPORT_DATA_SOURCE}).getSubDataSourceFromRow("Tasks")]]></dataSourceExpression>

...

</subreport>

 

3. Or will this not work within the IReport tool and I have to run this outside the tool? But then what good is the tool if I cannot observe the simplest of test data being processed by Jasper?

 

Ken

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...