JasperReport 评估表达式时出错:源文本:新 java.lang.Integer(1)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18061733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:08:16  来源:igfitidea点击:

JasperReport Error evaluating expression: Source text : new java.lang.Integer(1)

javajasper-reports

提问by kripton haz

I'm using JasperSoft Studio 5.1.0 for creating my report. This is library I used so far

我正在使用 JasperSoft Studio 5.1.0 创建我的报告。这是我到目前为止使用的库

  • commons-beanutils-1.8.3.jar commons-collections.jar commons-digester-1.7.jar commons-javaflow-20060411.jar commons-logging-1.1.3.jar groovy-all-1.7.5.jar itext-2.1.7.jar jasperreports-5.1.0.jar
  • commons-beanutils-1.8.3.jar commons-collections.jar commons-digester-1.7.jar commons-javaflow-20060411.jar commons-logging-1.1.3.jar groovy-all-1.7.5.jar itext-2.1。 7.jar jasperreports-5.1.0.jar

I'm trying using parameter and it's not showing any error when I see the preview on JasperSoft Studio, but when I try to print from my Java program it's show an error like this:

我正在尝试使用参数,当我在 JasperSoft Studio 上看到预览时它没有显示任何错误,但是当我尝试从我的 Java 程序打印时它显示如下错误:

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : new java.lang.Integer(1)

net.sf.jasperreports.engine.fill.JRExpressionEvalException:评估表达式时出错:源文本:new java.lang.Integer(1)

the code I use on my program for action performed is like this

我在我的程序中用于执行操作的代码是这样的

try
{
   String NamaFile = "src/Laporan Penawaran.jasper";
   Class.forName("com.mysql.jdbc.Driver").newInstance();
   Connection konek = Koneksi.getKoneksi();
   HashMap hash = new HashMap();
   hash.put("param1",no_tender.getText());

   File file = new File(NamaFile);
   JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file.getPath());
   JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, hash,konek);
   JasperViewer.viewReport(jasperPrint);
} catch(Exception ex) {
   System.out.println(ex);
}

I just wondering maybe my jasper file is error, but when I try to erase all field and using only static text the error still exist. What am I supposed to do?

我只是想知道我的 jasper 文件可能是错误的,但是当我尝试擦除所有字段并仅使用静态文本时,错误仍然存​​在。我应该做些什么?

回答by kripton haz

well I'm just trying to update groovy-all to version 2. And after that there's no problem at all and work smoothly :)

好吧,我只是想将 groovy-all 更新到版本 2。之后就完全没有问题并且工作顺利了:)

note: make sure you are using a specific version for each library, somehow the new one it's not always match for your report

注意:确保您为每个库使用特定版本,不知何故新版本并不总是与您的报告匹配

回答by Squid

Below is whole stack trace by which I was able to identify the issue.

以下是我能够识别问题的整个堆栈跟踪。

net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
    Source text : new java.lang.Integer(1)
    at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:782)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:331)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:384)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:358)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:458)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnHeader(JRVerticalFiller.java:502)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:284)
    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.JRFillSubreport.fillSubreport(JRFillSubreport.java:651)
    at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
    at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:203)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
    Source text : new java.lang.Integer(1)
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:308)
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:582)
    at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:181)
    at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1234)
    at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1208)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1577)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:149)
    ... 8 more
Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8
    at ReconciliationDetail_UnclearedTxn_ChecksAndPayments_Count_1450338812203_279237.evaluateEstimated(calculator_ReconciliationDetail_UnclearedTxn_ChecksAndPayments_Count_1450338812203_279237:272)
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:295)
    ... 14 more
**Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.BytecodeInterface8**
    at java.lang.ClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 16 more

FIX Worked for me

FIX 为我工作

  • I have updated all reports/subreports language property from "groovy"to "Java"and it's fixed .
  • Though it looks like workaround I suggest to update library which will include the missing class in jasperreports-5.1.2.jar.
  • 我已将所有报告/子报告语言属性从"groovy"to更新为已"Java"修复。
  • 虽然看起来像解决方法,但我建议更新库,其中将包含jasperreports-5.1.2.jar.

回答by Sergey

FIX for me: i changed type of fields from java.math.BigInteger to java.math.BigDecimal

为我修复:我将字段类型从 java.math.BigInteger 更改为 java.math.BigDecimal