java - Jaspersoft Studio complains class cast exception when using JRBeanCollectionDataSource -
java - Jaspersoft Studio complains class cast exception when using JRBeanCollectionDataSource -
i have weird problem jaspersoft studio , custom jrbeancollectiondatasource.
every time seek access kid object of parent object, exception this:
net.sf.jasperreports.engine.jrexception: net.sf.jasperreports.engine.fill.jrexpressionevalexception: error evaluating look : source text : $f{test}.getfirst() + " " + $f{test}.getsecond() @ com.jaspersoft.studio.editor.preview.view.control.reportcontroler.fillreport(reportcontroler.java:466) @ com.jaspersoft.studio.editor.preview.view.control.reportcontroler.access$18(reportcontroler.java:441) @ com.jaspersoft.studio.editor.preview.view.control.reportcontroler$4.run(reportcontroler.java:333) @ org.eclipse.core.internal.jobs.worker.run(worker.java:54) caused by: net.sf.jasperreports.engine.fill.jrexpressionevalexception: error evaluating look : source text : $f{test}.getfirst() + " " + $f{test}.getsecond() @ net.sf.jasperreports.engine.fill.jrevaluator.evaluate(jrevaluator.java:263) @ net.sf.jasperreports.engine.fill.jrcalculator.evaluate(jrcalculator.java:611) @ net.sf.jasperreports.engine.fill.jrcalculator.evaluate(jrcalculator.java:579) @ net.sf.jasperreports.engine.fill.jrfillelement.evaluateexpression(jrfillelement.java:1016) @ net.sf.jasperreports.engine.fill.jrfilltextfield.evaluatetext(jrfilltextfield.java:504) @ net.sf.jasperreports.engine.fill.jrfilltextfield.evaluate(jrfilltextfield.java:488) @ net.sf.jasperreports.engine.fill.jrfillelementcontainer.evaluate(jrfillelementcontainer.java:259) @ net.sf.jasperreports.engine.fill.jrfillband.evaluate(jrfillband.java:456) @ net.sf.jasperreports.engine.fill.jrverticalfiller.fillbandnooverflow(jrverticalfiller.java:467) @ net.sf.jasperreports.engine.fill.jrverticalfiller.fillcolumnheader(jrverticalfiller.java:512) @ net.sf.jasperreports.engine.fill.jrverticalfiller.fillreportstart(jrverticalfiller.java:294) @ net.sf.jasperreports.engine.fill.jrverticalfiller.fillreport(jrverticalfiller.java:152) @ net.sf.jasperreports.engine.fill.jrbasefiller.fill(jrbasefiller.java:963) @ net.sf.jasperreports.engine.fill.basefillhandle$reportfiller.run(basefillhandle.java:120) @ java.lang.thread.run(thread.java:745) caused by: java.lang.classcastexception: mypacket.test cannot cast mypacket.test @ blank_a4_1403082997789_739077.evaluate(blank_a4_1403082997789_739077:169) @ net.sf.jasperreports.engine.fill.jrevaluator.evaluate(jrevaluator.java:250) ... 14 more
here relevant classes:
public class rootfactory { public static jrbeancollectiondatasource get() { homecoming new jrbeancollectiondatasource(arrays.aslist(new rootclass(new test()))); } } public class rootclass { private test test; public rootclass(test test) { this.test = test; } public test gettest() { homecoming test; } public void settest(test test) { this.test = test; } } public class test { private string first = "first"; private string sec = "second"; public string getfirst() { homecoming first; } public void setfirst(string first) { this.first = first; } public string getsecond() { homecoming second; } public void setsecond(string second) { this.second = second; } }
i've added classes jaspersoft studio , added info adapter utilize rootfactory.get() method , seems working.
field look in jasper $f{test}.getfirst() + " " + $f{test}.getsecond()
weird thing jasper can't cast mypacket.test mypacket.test.
any clues how solve this?
- jaspersoft studio 5.6.0 - java 1.7.0_11edit 1
here jrxml file
<?xml version="1.0" encoding="utf-8"?> <!-- created jaspersoft studio version last--> <jasperreport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="blank_a4" pagewidth="595" pageheight="842" columnwidth="555" leftmargin="20" rightmargin="20" topmargin="20" bottommargin="20" uuid="a333429d-13c8-4db0-849e-9ed3fa97af6e"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="tempfactory"/> <querystring> <![cdata[]]> </querystring> <field name="test" class="mypacket.test"/> <background> <band splittype="stretch"/> </background> <title> <band height="79" splittype="stretch"/> </title> <pageheader> <band height="35" splittype="stretch"/> </pageheader> <columnheader> <band height="61" splittype="stretch"> <textfield> <reportelement x="0" y="0" width="555" height="61" uuid="0ca07834-5483-4ad5-a7fc-b415c2cce367"/> <textfieldexpression><![cdata[$f{test}.getfirst() + " " + $f{test}.getsecond()]]></textfieldexpression> </textfield> </band> </columnheader> <detail> <band height="125" splittype="stretch"/> </detail> <columnfooter> <band height="45" splittype="stretch"/> </columnfooter> <pagefooter> <band height="54" splittype="stretch"/> </pagefooter> <summary> <band height="42" splittype="stretch"/> </summary> </jasperreport>
and if matter: utilize osx 10.9.2.
i have faced similar exceptions in both 5.5.2 , 5.6, ...cannot cast t t... t a) exact same type b) own pojo derived fr jrabstractbeandatasource
i know not solution , think should filed jasper guys... plain "restarting jasper studio" helped :-/ 1 of many little things in studio...
hope kinda helps nonetheless
java jasper-reports jaspersoft-studio
Comments
Post a Comment