net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions

0

Hello Team,

Now i starting learning of JasperReport. I've installed JasperStudio in Eclipse Helios.

I've created the jrxml file for fetching records from sql database. I created this file successfully using this jasper studio utility.

if i click the preview, it shows all rows correctly. I'm using jdk 1.6. But here it gives some type casting error.

When i try to execute the java program to generate the report pdf, i'm getting the below error:: Errors were encountered when compiling report expressions class file:

 

at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(

at net.sf.jasperreports.engine.JasperCompileManager.compileReport(

at net.sf.jasperreports.engine.JasperCompileManager.compileReport(

at JasperReportsIntro.main(

JRAbstractCompiler.java:195)JasperCompileManager.java:219)JasperCompileManager.java:152)JasperReportsIntro.java:18)

Let me know what is the cause of this error and how to resolve this? Thank you.

net.sf.jasperreports.engine.JRException

1. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)variable_PAGE_NUMBER.getValue())); //$JR_EXPR_ID=9$

<---------------------------------------------------------------------->

2. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)variable_PAGE_NUMBER.getValue())); //$JR_EXPR_ID=10$

<---------------------------------------------------------------------->

3. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)field_Age.getValue())); //$JR_EXPR_ID=12$

<----------------------------------------------------------->

4. Cannot cast from Date to String

value = (java.lang.String)(new java.util.Date()); //$JR_EXPR_ID=14$

<-------------------------------------->

5. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)variable_PAGE_NUMBER.getOldValue())); //$JR_EXPR_ID=9$

<------------------------------------------------------------------------->

6. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)variable_PAGE_NUMBER.getOldValue())); //$JR_EXPR_ID=10$

<------------------------------------------------------------------------->

7. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)field_Age.getOldValue())); //$JR_EXPR_ID=12$

<-------------------------------------------------------------->

8. Cannot cast from Date to String

value = (java.lang.String)(new java.util.Date()); //$JR_EXPR_ID=14$

<-------------------------------------->

9. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)variable_PAGE_NUMBER.getEstimatedValue())); //$JR_EXPR_ID=9$

<------------------------------------------------------------------------------->

10. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)variable_PAGE_NUMBER.getEstimatedValue())); //$JR_EXPR_ID=10$

<------------------------------------------------------------------------------->

11. Cannot cast from Integer to String

value = (java.lang.String)(((java.lang.Integer)field_Age.getValue())); //$JR_EXPR_ID=12$

<----------------------------------------------------------->

12. Cannot cast from Date to String

value = (java.lang.String)(new java.util.Date()); //$JR_EXPR_ID=14$

<-------------------------------------->

12 errors

tskarthic's picture
Joined: Jul 15 2011 - 11:07am
Last seen: 8 years 1 month ago

3 Answers:

0

I believe this is due to a bug I just posted about regarding stripping out of the class attribute in all the textFieldExpression elements. I think the only way around it is to go back to the older version.

mrobinson's picture
Joined: Oct 3 2006 - 8:26am
Last seen: 1 year 5 months ago
1

I was able to get around this problem by specifying converting to string when using a non-string field

ie: $F{windowWidth}.toString() + " W  x " + $F{windowHeight}.toString() + " H"

ldstork's picture
13
Joined: Dec 8 2010 - 9:52am
Last seen: 8 years 8 months ago
1

Change your library . İf you use 5.0.0  and lower you take error. You have to change 6.x.x otherwise you don't use equals etc...

malik.masis's picture
Joined: Oct 15 2016 - 9:19pm
Last seen: 2 years 7 months ago
Feedback
randomness