[#4527] - When running a report, generated with iReport-NB, erroneous class casts occur

Category:
Bug report
Priority:
High
Status:
Assigned
Project: Severity:
Major
Resolution:
Fixed
Component: Reproducibility:
Always
Assigned to:

When i generat a report with iReport-NB, which should display one of our businesslogic objects a erroneous and unnecessary class cast is performed, which leads to an exception:

Creating entity manager
Closing entity manager
Error filling print... Error evaluating expression :      Source text : ""+$F{postalcode}
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :      Source text : ""+$F{postalcode}      at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:193)      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:570)      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:538)      at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:868)      at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:368)      at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:353)      at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:256)      at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:482)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2011)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:749)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:252)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:110)      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:923)      at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:119)      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:435)      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:271)      at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:934)      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)      at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)  Caused by: java.lang.ClassCastException: com.vendidata.gollum.businesslogic.Postalcode cannot be cast to com.vendidata.gollum.businesslogic.Postalcode      at report2_1263370358444_390829.evaluate(report2_1263370358444_390829:179)      at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:182)      ... 18 more 
Print not filled. Try to use an EmptyDataSource...

Here Postalcode is tried to be casted to Postalcode, which is oviously unnecessary. Postalcode has the toString()-method implemented correctly.

When i try to design the same report (with the same EJB-QL/JPA/EclipseLink backend) in iReport-3.0 (non Netbeans version) it works perfectly fine.

I also attach the .jrxml file to this issue.

AttachmentSize
Binary Data report2.jrxml1.86 KB
t3_chris's picture
253
Joined: May 25 2008 - 11:20pm
Last seen: 8 months 2 weeks ago

15 Comments:

#1

This bug is caused by Apache Commons BeansUtils 1.8.0

As soon as i exchanged this library by the updated 1.8.2 release, everything worked as expected.

I've exchanged the file in:
C:\Program Files\JasperSoft\iReport-3.7.0\ireport\modules\ext\commons-beanutils-1.8.0.jar

Of cource, i had to rename it from commons-beanutils-1.8.2.jar to commons-beanutils-1.8.2.jar prior to replacing it.

#2

For Details see note 0008750

#3

We may update the BeansUtils jar, but were you able to understand what the bug is exactely? I looks to me more like a class loading error (like if com.vendidata.gollum.businesslogic.Postalcode is loaded by two different classloaders leading in a cast exception for the same class name).

Thanks

Giulio

#4

Hello Giulio!

I am quite sure, you're right with your assumption, saying my problems are class-loading issues. The described problem persists up to and including iReport-4.5.0.

Is there any way I can track down this problems?
I think part of the problem is, that my businesslogic (which holds the JPA classes) relies on quite some external libraries.

Thanks in advance for your help!

Christian

#5

i have the same problem now.I use iReport-4.5.0 and commons-beanutils-1.8.2.jar.But the problem is still there.Can you help me?

#6
  • Priority:Normal» High

Similar error here using Jaspersoft Studio 6.3 (commons-beanutils-1.9.0.jar) and JDK 1.7:

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: new JRBeanCollectionDataSource( java.util.Arrays.asList( $F{student} ) )
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:537)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:512)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:393)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: new JRBeanCollectionDataSource( java.util.Arrays.asList( $F{student} ) )
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:290)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:616)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:584)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1164)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:450)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:341)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillSummaryNoLastFooterSamePage(JRVerticalFiller.java:1064)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillSummary(JRVerticalFiller.java:1025)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportEnd(JRVerticalFiller.java:286)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:122)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:123)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: ca.bc.gov.educ.isd.reports.data.impl.Student cannot be cast to ca.bc.gov.educ.isd.reports.data.impl.Student
at Exam32Transcripts32Scholarships32Master_1467906872486_428847.evaluate(Exam32Transcripts32Scholarships32Master_1467906872486_428847:533)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:276)
... 14 more

--

<field name="student" class="ca.bc.gov.educ.isd.reports.data.impl.Student">
<fieldDescription><![CDATA[student]]></fieldDescription>
</field>

--

<subreport>
<reportElement x="0" y="10" width="572" height="30" isRemoveLineWhenBlank="true" uuid="bbf231f1-70e7-4092-be72-cc275cc3860e"/>
<dataSourceExpression><![CDATA[new JRBeanCollectionDataSource( java.util.Arrays.asList( $F{student} ) )]]></dataSourceExpression>
<subreportExpression><![CDATA["SUMMARY_" + ($P{P_REPORT_TYPE}.trim().toUpperCase().startsWith("TG") ? "TG" : $P{P_REPORT_TYPE}) + ".jasper"]]></subreportExpression>
</subreport>

--

The report runs several times in a row before the exception occurs.

Note that the .classpath file was manually edited to use relative paths because the UI does not offer a way to set a relative path. (This is required because we're in a multi-developer environment and each developer can have a different fully qualified path to the build directory, but the relative path is enforced by the repository structure. If all developers had the same working directory hierarchy, absolute paths would work. Alas, they don't.)

I can send the JRXML by e-mail but cannot make it available to the general public.

As far as I can tell, there is only one Student class (ca.bc.gov.educ.isd.reports.data.impl.Student) on the CLASSPATH. There are no other JAR files or directories with .class files or system environment settings that point to another instance of Student.

Restarting Jaspersoft Studio temporarily resolves the issue.

AttachmentSize
Image icon java-build-path.png36.53 KB
Image icon project-explorer.png36.77 KB
File studentadapter.xml338 bytes
Binary Data classpath680 bytes
#7

could you send your workspace to me by email? so I can see exactly how you set classpath, project, etc.

just remove all confidential information

#8

If I get permission, I can send more information.

Meanwhile, find attached a couple of screenshots that show more information about the problem.

AttachmentSize
Image icon report-problems.png40.89 KB
Image icon classpath.png24.09 KB
#9

Another detail: the problems shown in report-problems.png only occur upon startup of Jaspersoft Studio. Once I click "Build All", the 9 problems go away. However, previewing the report several times will still result in having to restart the IDE due to the aforementioned exception.

#10

...And sometimes the error is triggered on the first preview after a restart and build. See attached.

AttachmentSize
Image icon error-message.png15.91 KB
#11
  • Resolution:Reopened» Fixed
  • Assigned:giulio» chicuslavic

Confirmed fixed on 6.3.1 SNAPSHOT.

#12
  • Status:Feedback Requested» Resolved
#13
  • Resolution:Fixed» Reopened
  • Status:Resolved» Assigned

Am able to reproduce the same error:

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: new JRBeanCollectionDataSource( java.util.Arrays.asList( $F{student} ) )
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:537)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:512)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:393)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: new JRBeanCollectionDataSource( java.util.Arrays.asList( $F{student} ) )
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:290)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:616)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:584)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1164)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:450)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:341)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:427)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:388)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:249)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:123)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: ca.bc.gov.educ.isd.reports.data.impl.Student cannot be cast to ca.bc.gov.educ.isd.reports.data.impl.Student
at Exam32Transcripts32Scholarships32Master_1471979058362_192151.evaluate(Exam32Transcripts32Scholarships32Master_1471979058362_192151:526)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:276)
... 14 more

Version information attached. (Would be nice to have a way to copy/paste the version from within the UI...)

AttachmentSize
Image icon js-studio.png122.62 KB
#14

Replicate

0. Open a report (as usual).
1. Open its style file.
2. Edit the corresponding .jrtx file.
3. Save the .jrtx file.
4. Click "Build All"
5. Return to the report.
6. Click Play (run the report).

Expected Results

The report runs and the new styles are applied.

Actual Results

Class Cast Exception (see previous comment).

#15
  • Resolution:Reopened» Fixed

After re-installing 6.3.1 final, the class cast exception no longer appears.

Additionally, scrolling with the mouse only seems to fail when Jaspersoft Studio 6.3.1 is launched from the installer. Running JS Studio 6.3.1 after it has been installed (not from the installer) allows wheel scrolling.

Feedback