1

我正在使用 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

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

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

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

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);
}

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

4

3 回答 3

1

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

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

于 2013-08-05T23:19:46.690 回答
0

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

于 2016-08-31T08:30:29.820 回答
-1

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

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 为我工作

  • 我已将所有报告/子报告语言属性从"groovy"to更新为"Java"已修复。
  • 虽然它看起来像解决方法,但我建议更新将在jasperreports-5.1.2.jar.
于 2015-12-17T08:04:14.720 回答