Getting net.sf.jasperreports.engine.JRRuntimeException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined Exception

0

While executing report with high chart stacked line. We are getting following exception

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"

Our Jrxml looks like below

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  --><!-- 2016-08-04T12:04:26 --><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.unit." value="pixel"/> <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/> <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/> <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/> <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/> <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">     <property name="local_mesure_unitheight" value="pixel"/>     <property name="com.jaspersoft.studio.unit.height" value="px"/>     <property name="local_mesure_unitwidth" value="pixel"/>     <property name="com.jaspersoft.studio.unit.width" value="px"/>     <property name="local_mesure_unitx" value="pixel"/>     <property name="com.jaspersoft.studio.unit.x" value="px"/>     <property name="local_mesure_unity" value="pixel"/>     <property name="com.jaspersoft.studio.unit.y" value="px"/>    </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>   <image>    <reportElement x="552" y="0" width="146" height="26" uuid="b240b6f0-a715-4d36-8783-935d7ecc0241">     <property name="local_mesure_unitwidth" value="pixel"/>     <property name="com.jaspersoft.studio.unit.width" value="px"/>     <property name="local_mesure_unitheight" value="pixel"/>     <property name="com.jaspersoft.studio.unit.height" value="px"/>     <property name="local_mesure_unitx" value="pixel"/>     <property name="com.jaspersoft.studio.unit.x" value="px"/>    </reportElement>    <imageExpression><![CDATA["logo.png"]]></imageExpression>   </image>   <staticText>    <reportElement x="80" y="132" width="570" height="118" uuid="572c742c-d9d7-4893-832c-e106640f41fc">     <printWhenExpression><![CDATA[$V{REPORT_COUNT}==0]]></printWhenExpression>    </reportElement>    <textElement textAlignment="Center">     <font fontName="Arial" size="14"/>    </textElement>    <text><![CDATA[The report is empty.]]></text>   </staticText>   <staticText>    <reportElement x="85" y="170" width="570" height="118" uuid="572c742c-d9d7-4893-832c-e106640f41fc">     <printWhenExpression><![CDATA[$P{FromDate}.getStart().getTime()>TODAY().getTime()]]></printWhenExpression>    </reportElement>    <textElement textAlignment="Center">     <font fontName="Arial" size="14"/>    </textElement>    <text><![CDATA[From Date should be earlier than Today.]]></text>   </staticText>   <staticText>    <reportElement x="85" y="210" width="570" height="118" uuid="572c742c-d9d7-4893-832c-e106640f41fc">     <printWhenExpression><![CDATA[$P{FromDate}.getStart().getTime()>$P{ToDate}.getStart().getTime()]]></printWhenExpression>    </reportElement>    <textElement textAlignment="Center">     <font fontName="Arial" size="14"/>    </textElement>    <text><![CDATA[From Date should be earlier than To Date.]]></text>   </staticText>  </band> </summary></jasperReport>

Is there somethig wrong with the jrxml? The data returned from the sql statement is empty. So it prints report is empty after that there are exceptions are printed.

Jasper server version is 6.1

dheeraj.madhu's picture
Joined: Aug 8 2013 - 10:27pm
Last seen: 3 years 3 months ago

For some reason I can not properly align the xml in here. And I have ommitted few attributes etc fro jrxml. Please assume they are there

dheeraj.madhu - 3 years 6 months ago

1 Answer:

0
Issue is solved.
 
When the data set is empty high chart still try to render the chart and it will fail. To prevent it added print when condition for chart element in report jrxml.
<printWhenExpression><![CDATA[$V{REPORT_COUNT} > 0]]></printWhenExpression>
dheeraj.madhu's picture
Joined: Aug 8 2013 - 10:27pm
Last seen: 3 years 3 months ago
Feedback