在 JasperReports Server 呈现图表时出现 'Cannot read property "length" from undefined' 异常
Getting 'Cannot read property "length" from undefined' exception while rendering chart at JasperReports Server
生成具有高图表堆叠线的报告时得到
net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
完整追踪
2016-08-04 01:32:43,508 ERROR AsyncThumbnailCreatorImpl,pool-29-thread-2:59 - net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
at com.jaspersoft.jasperreports.highcharts.charts.ChartGraphics2DHandler.exportElement(ChartGraphics2DHandler.java:52)
at net.sf.jasperreports.engine.export.draw.FrameDrawer.draw(FrameDrawer.java:246)
at net.sf.jasperreports.engine.export.draw.FrameDrawer.draw(FrameDrawer.java:198)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportPage(JRGraphics2DExporter.java:342)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportReportToGraphics2D(JRGraphics2DExporter.java:311)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportReport(JRGraphics2DExporter.java:236)
at net.sf.jasperreports.engine.print.JRPrinterAWT.printPageToImage(JRPrinterAWT.java:290)
at net.sf.jasperreports.engine.JasperPrintManager.printToImage(JasperPrintManager.java:290)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.ThumbnailGenerationServiceImpl.obtainImage(ThumbnailGenerationServiceImpl.java:71)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.ThumbnailGenerationServiceImpl.createThumbnail(ThumbnailGenerationServiceImpl.java:50)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.ThumbnailGenerationServiceImpl.createThumbnail(ThumbnailGenerationServiceImpl.java:24)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.AsyncThumbnailCreatorImpl$ThumbnailRunnable.run(AsyncThumbnailCreatorImpl.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3785)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3763)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3791)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3810)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3823)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1508)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1398)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_anonymous_7(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:46)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_99(com.jaspersoft.jasperreports.highcharts.render.r.js:1889)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_55(com.jaspersoft.jasperreports.highcharts.render.r.js:1105)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_67(com.jaspersoft.jasperreports.highcharts.render.r.js:1382)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_49(com.jaspersoft.jasperreports.highcharts.render.r.js:1013)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_89(com.jaspersoft.jasperreports.highcharts.render.r.js:1655)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:57)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_104(com.jaspersoft.jasperreports.highcharts.render.r.js:1996)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_localRequire_88(com.jaspersoft.jasperreports.highcharts.render.r.js:1644)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_102(com.jaspersoft.jasperreports.highcharts.render.r.js:1976)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_anonymous_6(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:45)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_anonymous_5(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:41)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_99(com.jaspersoft.jasperreports.highcharts.render.r.js:1889)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_55(com.jaspersoft.jasperreports.highcharts.render.r.js:1105)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_67(com.jaspersoft.jasperreports.highcharts.render.r.js:1382)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_49(com.jaspersoft.jasperreports.highcharts.render.r.js:1013)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_89(com.jaspersoft.jasperreports.highcharts.render.r.js:1655)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:57)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_104(com.jaspersoft.jasperreports.highcharts.render.r.js:1996)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_localRequire_88(com.jaspersoft.jasperreports.highcharts.render.r.js:1644)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_102(com.jaspersoft.jasperreports.highcharts.render.r.js:1976)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_renderSVGFromJson_4(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:31)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
at org.mozilla.javascript.Context.evaluateString(Context.java:1111)
at com.jaspersoft.jasperreports.highcharts.charts.render.RhinoChartSvgProducer.getChartSvg(RhinoChartSvgProducer.java:104)
at com.jaspersoft.jasperreports.highcharts.charts.render.DefaultChartSvgProducer.getChartSvg(DefaultChartSvgProducer.java:39)
at com.jaspersoft.jasperreports.highcharts.charts.render.ChartSvgImageProducer.createRenderable(ChartSvgImageProducer.java:81)
at com.jaspersoft.jasperreports.highcharts.charts.render.ChartSvgImageProducer.getChartImage(ChartSvgImageProducer.java:45)
at com.jaspersoft.jasperreports.highcharts.charts.ChartGraphics2DHandler.exportElement(ChartGraphics2DHandler.java:47)
... 16 more
jrxml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="AbandonedWorkflowPercentage" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fc97a963-c0b6-4c19-a348-7e2773e092a3">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DM"/>
<queryString language="SQL">
<![CDATA[SELECT ...]]>
</queryString>
<field name="INTERVALS" class="java.util.Date"/>
<field name="PERCENTAGE_TO_GOAL" class="java.math.BigDecimal"/>
<field name="TOTAL" class="java.math.BigDecimal"/>
<field name="SERIES" class="java.lang.String"/>
<summary>
<band height="550" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<componentElement>
<reportElement x="0" y="50" width="700" height="500" uuid="edf50a68-78c7-45b6-8246-57d927666a3d">
</reportElement>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="StackedLine">
<hc:chartSetting name="default">
<hc:chartProperty name="chart.zoomType">
<hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.href">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="xAxis.labels.rotation">
<hc:propertyExpression><![CDATA[new Integer(-45)]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="yAxis.title.text">
<hc:propertyExpression><![CDATA["Percent To Goal"]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Interval">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.String">
<bucketExpression><![CDATA[$F{INTERVALS}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns">
<axisLevel name="series">
<labelExpression><![CDATA[]]></labelExpression>
<axisLevelBucket order="None" class="java.lang.String">
<bucketExpression><![CDATA[$F{SERIES}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<multiAxisMeasure name="PercentToGoal" class="java.math.BigDecimal" calculation="Nothing">
<labelExpression><![CDATA[""]]></labelExpression>
<valueExpression><![CDATA[$F{PERCENTAGE_TO_GOAL}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="PercentToGoal"/>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>
没有编译错误,SQL返回空数据。所以报告打印 "Empty report" 但之后日志中出现上述异常
问题已解决。
当数据集为空时,高图表仍然尝试渲染图表,但它会失败。为防止它在报告 jrxml 中为图表元素添加条件时打印。
<printWhenExpression><![CDATA[$V{REPORT_COUNT} > 0]]></printWhenExpression>
生成具有高图表堆叠线的报告时得到
net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
完整追踪
2016-08-04 01:32:43,508 ERROR AsyncThumbnailCreatorImpl,pool-29-thread-2:59 - net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
at com.jaspersoft.jasperreports.highcharts.charts.ChartGraphics2DHandler.exportElement(ChartGraphics2DHandler.java:52)
at net.sf.jasperreports.engine.export.draw.FrameDrawer.draw(FrameDrawer.java:246)
at net.sf.jasperreports.engine.export.draw.FrameDrawer.draw(FrameDrawer.java:198)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportPage(JRGraphics2DExporter.java:342)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportReportToGraphics2D(JRGraphics2DExporter.java:311)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportReport(JRGraphics2DExporter.java:236)
at net.sf.jasperreports.engine.print.JRPrinterAWT.printPageToImage(JRPrinterAWT.java:290)
at net.sf.jasperreports.engine.JasperPrintManager.printToImage(JasperPrintManager.java:290)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.ThumbnailGenerationServiceImpl.obtainImage(ThumbnailGenerationServiceImpl.java:71)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.ThumbnailGenerationServiceImpl.createThumbnail(ThumbnailGenerationServiceImpl.java:50)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.ThumbnailGenerationServiceImpl.createThumbnail(ThumbnailGenerationServiceImpl.java:24)
at com.jaspersoft.jasperserver.api.metadata.common.service.impl.AsyncThumbnailCreatorImpl$ThumbnailRunnable.run(AsyncThumbnailCreatorImpl.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (com/jaspersoft/jasperreports/highcharts/charts/render/scripts/jquery-1.10.2.min.js#4)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3785)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3763)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3791)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3810)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3823)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1508)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1398)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_anonymous_7(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:46)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_99(com.jaspersoft.jasperreports.highcharts.render.r.js:1889)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_55(com.jaspersoft.jasperreports.highcharts.render.r.js:1105)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_67(com.jaspersoft.jasperreports.highcharts.render.r.js:1382)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_49(com.jaspersoft.jasperreports.highcharts.render.r.js:1013)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_89(com.jaspersoft.jasperreports.highcharts.render.r.js:1655)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:57)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_104(com.jaspersoft.jasperreports.highcharts.render.r.js:1996)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_localRequire_88(com.jaspersoft.jasperreports.highcharts.render.r.js:1644)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_102(com.jaspersoft.jasperreports.highcharts.render.r.js:1976)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_anonymous_6(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:45)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_anonymous_5(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:41)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2521)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:300)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_99(com.jaspersoft.jasperreports.highcharts.render.r.js:1889)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_55(com.jaspersoft.jasperreports.highcharts.render.r.js:1105)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_67(com.jaspersoft.jasperreports.highcharts.render.r.js:1382)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_49(com.jaspersoft.jasperreports.highcharts.render.r.js:1013)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_89(com.jaspersoft.jasperreports.highcharts.render.r.js:1655)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:57)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_104(com.jaspersoft.jasperreports.highcharts.render.r.js:1996)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_localRequire_88(com.jaspersoft.jasperreports.highcharts.render.r.js:1644)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1._c_anonymous_102(com.jaspersoft.jasperreports.highcharts.render.r.js:1976)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_r_js_1.call(com.jaspersoft.jasperreports.highcharts.render.r.js)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2._c_renderSVGFromJson_4(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js:31)
at org.mozilla.javascript.gen.com_jaspersoft_jasperreports_highcharts_render_svg_renderer_highcharts_js_2.call(com.jaspersoft.jasperreports.highcharts.render.svg-renderer-highcharts.js)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
at org.mozilla.javascript.Context.evaluateString(Context.java:1111)
at com.jaspersoft.jasperreports.highcharts.charts.render.RhinoChartSvgProducer.getChartSvg(RhinoChartSvgProducer.java:104)
at com.jaspersoft.jasperreports.highcharts.charts.render.DefaultChartSvgProducer.getChartSvg(DefaultChartSvgProducer.java:39)
at com.jaspersoft.jasperreports.highcharts.charts.render.ChartSvgImageProducer.createRenderable(ChartSvgImageProducer.java:81)
at com.jaspersoft.jasperreports.highcharts.charts.render.ChartSvgImageProducer.getChartImage(ChartSvgImageProducer.java:45)
at com.jaspersoft.jasperreports.highcharts.charts.ChartGraphics2DHandler.exportElement(ChartGraphics2DHandler.java:47)
... 16 more
jrxml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="AbandonedWorkflowPercentage" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fc97a963-c0b6-4c19-a348-7e2773e092a3">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DM"/>
<queryString language="SQL">
<![CDATA[SELECT ...]]>
</queryString>
<field name="INTERVALS" class="java.util.Date"/>
<field name="PERCENTAGE_TO_GOAL" class="java.math.BigDecimal"/>
<field name="TOTAL" class="java.math.BigDecimal"/>
<field name="SERIES" class="java.lang.String"/>
<summary>
<band height="550" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<componentElement>
<reportElement x="0" y="50" width="700" height="500" uuid="edf50a68-78c7-45b6-8246-57d927666a3d">
</reportElement>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="StackedLine">
<hc:chartSetting name="default">
<hc:chartProperty name="chart.zoomType">
<hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.href">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="xAxis.labels.rotation">
<hc:propertyExpression><![CDATA[new Integer(-45)]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="yAxis.title.text">
<hc:propertyExpression><![CDATA["Percent To Goal"]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Interval">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.String">
<bucketExpression><![CDATA[$F{INTERVALS}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns">
<axisLevel name="series">
<labelExpression><![CDATA[]]></labelExpression>
<axisLevelBucket order="None" class="java.lang.String">
<bucketExpression><![CDATA[$F{SERIES}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<multiAxisMeasure name="PercentToGoal" class="java.math.BigDecimal" calculation="Nothing">
<labelExpression><![CDATA[""]]></labelExpression>
<valueExpression><![CDATA[$F{PERCENTAGE_TO_GOAL}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="PercentToGoal"/>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>
没有编译错误,SQL返回空数据。所以报告打印 "Empty report" 但之后日志中出现上述异常
问题已解决。
当数据集为空时,高图表仍然尝试渲染图表,但它会失败。为防止它在报告 jrxml 中为图表元素添加条件时打印。
<printWhenExpression><![CDATA[$V{REPORT_COUNT} > 0]]></printWhenExpression>