我正在使用JasperSoft Studio 5.1.0来创建我的报告。这是我到目前为止使用的库
我正在尝试使用参数,当我在JasperSoft Studio上看到预览时它没有显示任何错误,但是当我尝试从我的Java程序打印时,它显示如下错误:
net.sf.jasperreports.engine.fill.JRExpressionEvalException:评估表达式时出错: 源文本:new 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文件可能是错误的,但当我尝试擦除所有字段并仅使用静态文本时,错误仍然存在。我应该做些什么?
答案 0 :(得分:1)
好吧,我只是想将groovy-all更新到版本2.然后就没有任何问题并且工作顺利了:)
注意:请确保您使用的是每个库的特定版本,不知何故新版本并不总是与您的报告相匹配
答案 1 :(得分:0)
对我来说是FIX: 我将字段类型从java.math.BigInteger更改为java.math.BigDecimal
答案 2 :(得分:-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"
更新为"Java"
,并且已修复。 jasperreports-5.1.2.jar
中缺少的类。