在我的网络应用程序中,我使用JasperReport 4和zxing jar来生成QR码。我已升级到JasperReports 6.0.3和zxing 2.2,现在我在尝试生成以前有效的报告时得到以下信息:
00000026 JRFillSubrepo E net.sf.jasperreports.engine.fill.JRFillSubreport prepare Fill 1: exception
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : JRImageRenderer.getInstance(com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(new com.google.zxing.qrcode.QRCodeWriter().encode($V{left_sn},com.google.zxing.BarcodeFormat.QR_CODE,300 ,150 )), JRRenderable.IMAGE_TYPE_PNG, JRImage.ON_ERROR_TYPE_ERROR)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:262)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:610)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:578)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1015)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:539)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:519)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:454)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2023)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:753)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:263)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:123)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:539)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:393)
at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:715)
at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:58)
at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:202)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
at java.lang.Thread.run(Thread.java:737)
Caused by: java.lang.NoSuchMethodError: net/sf/jasperreports/engine/JRImageRenderer.getInstance(Ljava/awt/Image;BB)Lnet/sf/jasperreports/engine/JRRenderable;
at SeatRowMatrixLeftSubReportV6_2_1410891674951_480225.evaluate(SeatRowMatrixLeftSubReportV6_2_1410891674951_480225:195)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:249)
... 19 more
答案 0 :(得分:0)
您使用的JRImageRenderer方法已在几个版本之前删除。
等效表达式如下所示:
net.sf.jasperreports.engine.RenderableUtil
.getInstance($P{JASPER_REPORTS_CONTEXT})
.getRenderable(
com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(
new com.google.zxing.qrcode.QRCodeWriter().encode(
$V{left_sn},
com.google.zxing.BarcodeFormat.QR_CODE,300 ,150
)
),
net.sf.jasperreports.engine.type.ImageTypeEnum.PNG,
net.sf.jasperreports.engine.type.OnErrorTypeEnum.ERROR
)