Crosstab issue with orderByExpression - jaspersoft 6.3.0

0

Trying to create a custom orderByExpression for my crosstab. Following the instructions in this link but keep getting the below error. What does this mean? And how do i troubleshoot?

https://stackoverflow.com/questions/37700673/sorting-in-crosstab-sort-co...

 

net.sf.jasperreports.engine.JRException: java.lang.NullPointerException
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:537)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:512)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:393)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.NullPointerException
    at net.sf.jasperreports.engine.fill.JRFillCrosstab$CrosstabFiller.setGroupMeasureVariables(JRFillCrosstab.java:2946)
    at net.sf.jasperreports.engine.fill.JRFillCrosstab$CrosstabFiller.prepareColumnHeader(JRFillCrosstab.java:2101)
    at net.sf.jasperreports.engine.fill.JRFillCrosstab$CrosstabFiller.fillColumnHeaders(JRFillCrosstab.java:1832)
    at net.sf.jasperreports.engine.fill.JRFillCrosstab$CrosstabFiller.fillVerticalCrosstab(JRFillCrosstab.java:1546)
    at net.sf.jasperreports.engine.fill.JRFillCrosstab$CrosstabFiller.fill(JRFillCrosstab.java:1470)
    at net.sf.jasperreports.engine.fill.JRFillCrosstab.prepare(JRFillCrosstab.java:805)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:536)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:411)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:386)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2024)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooter(JRVerticalFiller.java:913)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooters(JRVerticalFiller.java:779)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportEnd(JRVerticalFiller.java:284)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:122)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
    at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:123)
    at java.lang.Thread.run(Thread.java:745)


 

Perko's picture
8
Joined: Oct 22 2017 - 7:24pm
Last seen: 2 months 2 weeks ago

Wish to add that i'm trying to sort a RowGroup and not a ColumnGroup

Perko - 6 months 1 week ago

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0 -->
<!-- 2019-03-12T10:53:33 -->
<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="OrderByExpression" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e594cd70-98fa-4e14-bc59-58017c06d078">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Field_1" class="java.lang.String"/>
<field name="Field_2" class="java.lang.String"/>
<field name="Field_3" class="java.lang.String"/>
<field name="Field_4" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="205" splitType="Stretch">
<crosstab>
<reportElement x="5" y="5" width="535" height="200" uuid="ba187d4c-6935-4370-9558-006a75337876">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
</reportElement>
<rowGroup name="Field_2" width="60" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{Field_2}]]></bucketExpression>
<orderByExpression><![CDATA[$V{DataSort_Measure}]]></orderByExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="98e70d31-c42c-462f-b253-5df5d6b87e9a"/>
<textFieldExpression><![CDATA[$V{Field_2}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="f628e4d6-c859-409c-a384-da229a91f66b"/>
<text><![CDATA[Total Field_2]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="Field_1" height="20" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{Field_1}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="641cc53f-f14c-4fb4-99d7-dc5cb909a2b6"/>
<textFieldExpression><![CDATA[$V{Field_1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="141f4c6d-1244-4fad-97b2-dbd4b48b9855"/>
<text><![CDATA[Total Field_1]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="Field_3_MEASURE" class="java.lang.Integer" calculation="Count">
<measureExpression><![CDATA[$F{Field_3}]]></measureExpression>
</measure>
<measure name="DataSort_Measure" class="java.lang.Integer">
<measureExpression><![CDATA[0]]></measureExpression>
</measure>
<crosstabCell width="60" height="20">
<cellContents mode="Opaque" style="Crosstab_CD">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="bf216f6b-f0c6-46bd-94a4-249fd78fcdd2"/>
<textFieldExpression><![CDATA[$V{Field_3_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" columnTotalGroup="Field_1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="852f08ee-b07f-48ef-8666-b7c81afe0048"/>
<textFieldExpression><![CDATA[$V{Field_3_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="Field_2">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="17f75b05-14b0-4c57-a586-324f7e3d5dec"/>
<textFieldExpression><![CDATA[$V{Field_3_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="Field_2" columnTotalGroup="Field_1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="3e03ff3f-30b7-4da2-a6d7-4a7cf48e1c8c"/>
<textFieldExpression><![CDATA[$V{Field_3_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</summary>
</jasperReport>

Perko - 6 months 1 week ago

2 Answers:

0

It'd be good to look at the actual JRXML but my first guess would be that you $V{} is a variable and not a Measure.

In crosstabs you can't use variables but you need to use measures.

rpeguet's picture
6392
Joined: Mar 8 2011 - 2:06am
Last seen: 2 weeks 7 hours ago
0

Thanks for your response and providing feedback.

Have recreated the error using data source 'one empty record'  and posted the jrxml above. The jrxml gets the same error.

What have I done wrong? 

Thanks in advance.

Perko's picture
8
Joined: Oct 22 2017 - 7:24pm
Last seen: 2 months 2 weeks ago
Feedback
randomness