Currently, I am working in JasperReport Server and iReport. The version of JasperReport 5.5.0 and iReport are 5.5.0. And the database is MYSQL.
I declared the variable Dr like the following where am_primeamt
is coming from SQL query.
<variable name="Dr" class="java.lang.Double">
<variableExpression><![CDATA[($F{am_primeamt} > 0 ? $F{am_primeamt} : 0 )]]></variableExpression>
</variable>
And tried to show like following:
<textField pattern="#,##0.00">
<reportElement x="427" y="0" width="82" height="20" uuid="332ceda3-5237-40b5-a0ef-3aad009a7911">
<printWhenExpression><![CDATA[$V{Dr} != 0]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$V{Dr}]]></textFieldExpression>
When I am trying to see the preview it's showing the following error:
Error filling print... Error evaluating expression : Source text : $V{Dr} != 0 net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : $V{Dr} != 0 at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:244) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559) at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1016) at net.sf.jasperreports.engine.fill.JRFillElement.evaluatePrintWhenExpression(JRFillElement.java:795) at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:482) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:456) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2057) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:778) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:288) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:932) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:87) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891) 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: java.math.BigDecimal cannot be cast to java.lang.Double at gl_transaction_1454989470091_439976.evaluate(gl_transaction_1454989470091_439976:363) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:231) ... 20 more Print not filled. Try to use an EmptyDataSource...
Edited: Language is set java from the beginning and that showed the error like this. After making it groovy, it solved my problem.