java.lang.ClassCastException: java.lang.Integer cannot be cast to java.math.BigDecimal

0

Hi ,

                     

  I am having report1 and report2 , When I declare field

field name="Total " class="java.math.BigDecimal"

In report1, report2 and In report2,I am declare a variable as below

        variable name="sum_N_1" class="java.lang.BigDecimal" resetType="Group" resetGroup="report1" calculation="Sum"
        variableExpression  ![CDATA[$F{Total }]]  /variableExpression
        initialValueExpression   ![CDATA[0]]  /initialValueExpression
    /variable
    

Then

I am getting exception when I run report2 as fallows 

 

2013-03-13 21:11:14,103 ERROR JRFillSubreport,http-8080-1:742 - Fill 1: exception
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.math.BigDecimal
        at net.sf.jasperreports.engine.fill.JRBigDecimalSumIncrementer.increment(JRBigDecimalIncrementerFactory.java:335
        at net.sf.jasperreports.engine.fill.JRAbstractExtendedIncrementer.increment(JRAbstractExtendedIncrementer.java:4
        at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:144)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:742)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:285)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:132)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:746)
        at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:640)
        at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
        at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:205)
        at java.lang.Thread.run(Thread.java:662)

 

If I change to         variable name="sum_N_1" class="java.lang.Integer" resetType="Group" resetGroup="report1" calculation="Sum"  ,   I am able to run the report, I am not understand why the exception is coming.

Please help me ..

Thanks,

Raviraj

 

rsuddhala's picture
Joined: Aug 16 2012 - 10:55pm
Last seen: 9 months 3 weeks ago

1 Answer:

7

I would change your initialValueExpression to BigDecimal.valueOf(0)

bobtins's picture
172
Joined: Aug 17 2006 - 5:03pm
Last seen: 1 year 10 months ago

Thank you bobtins,Now I am able to run report..Thanks you very much..

rsuddhala - 6 years 2 months ago

Thank you for the solution

freelog3107 - 4 years 5 months ago

Thank you so much, this was killing me for hours, couldn't even pinpoint that the problem was in the variables

zilex - 1 year 10 months ago
Feedback