Jump to content

Error: Java.lang.ClassCastException: int cannot be cast into String


Go to solution Solved by lucianc,

Recommended Posts

Posted

Hi there,

i am trying to make a new Pie Chart. Everything worked out so far for different Charts, with Strings. Now I wanted to make an Pie chart with an Integer and this error occurs:

 

net.sf.jasperreports.engine.JRException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:511)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:486)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:367)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at net.sf.jasperreports.charts.fill.JRFillPieSeries.evaluate(JRFillPieSeries.java:135)
at net.sf.jasperreports.charts.fill.JRFillPieDataset.customEvaluate(JRFillPieDataset.java:198)
at net.sf.jasperreports.engine.fill.JRFillElementDataset.evaluate(JRFillElementDataset.java:162)
at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:187)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:742)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:262)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:122)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:555)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:119)
at java.lang.Thread.run(Unknown Source)
 
Im new to jaspersoft, so I don't really now how to handle this error.  Could anyone help me out, please?
 
Thank You
 
Cheers 
 
Marco
 
 
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution
Posted

The label expression in pie datasets is required to evaluate to Strings, and there is no automatic conversion from other types.

If you want an integer to display as label, you can use $V{value}.toString() or TEXT($V{value}, "#,###.00") if you want a specific format.

Regards,

Lucian

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