Jump to content

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

Go to solution Solved by bobtins,

Recommended Posts

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


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




Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 year later...
  • 2 years later...
  • 2 years later...
  • 1 year later...
  • 3 years 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...