Jump to content
Changes to the Jaspersoft community edition download ×

Class Cast exception: Jasper fails to thrill me


kjhuebner

Recommended Posts

It's hard to be optimistic after 3 days of fiddling with Jasper and IReport. Nonetheless I will describe my latest issue:

I get a Class Cast exception when retrieving a custom data source at the subreport level. And knowing there is no effective means to understand what's going on under the covers (since this tool is very deficient in providing such means to developers) I decided to do an experiment.

I wanted to determine what was in the REPORT_DATA_SOURCE property at the top of the master report.

So I setup a property to retrieve a value that I assumed to be my custom data source. (For my connection setup had already tested OK with my custom datasource "com.catalystwms.cct.web.beans.reports.TestDataSource")

But when I run this snippet of code in my report, out pops the Class cast exception. Why? Why doesn't this work? (All files are attached.)


((com.catalystwms.cct.web.beans.reports.TestDataSource)$P{REPORT_DATA_SOURCE})



IReport TRACE
==============
ÂTime zone: default
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_1154553627259_783159.evaluate(TestDataSource_1154553627259_783159:126) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:631) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:593) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:879) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:708) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685) ÂÂÂÂ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:728) ÂÂÂÂatÂjava.lang.Thread.run(UnknownÂSource) NESTEDÂBYÂ: java.lang.ClassCastException:Âcom.catalystwms.cct.web.beans.reports.TestDataSource ÂÂÂÂatÂTestDataSource_1154553627259_783159.evaluate(TestDataSource_1154553627259_783159:126) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:631) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:593) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:879) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:708) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685) ÂÂÂÂ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:728) ÂÂÂÂatÂjava.lang.Thread.run(UnknownÂSource) NESTEDÂBYÂ: net.sf.jasperreports.engine.fill.JRExpressionEvalException:ÂErrorÂevaluatingÂexpressionÂ:Â ÂÂÂÂSourceÂtextÂ:Â((com.catalystwms.cct.web.beans.reports.TestDataSource)$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:539) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:631) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:593) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:879) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:708) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685) ÂÂÂÂ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:728) ÂÂÂÂatÂjava.lang.Thread.run(UnknownÂSource) CausedÂby:Âjava.lang.ClassCastException:Âcom.catalystwms.cct.web.beans.reports.TestDataSource ÂÂÂÂatÂTestDataSource_1154553627259_783159.evaluate(TestDataSource_1154553627259_783159:126) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172) ÂÂÂÂ...Â11Âmore
PrintÂnotÂfilled.ÂTryÂtoÂuseÂanÂEmptyDataSource...!

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 1 year later...

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