Bom dia,
Eu já encontrei vários outros tópicos com o mesmo erro, mas não consegui exito com os procedimentos de nenhum deles.
Estou gerando um relatório no jasperStudio, só que estou recebendo o seguinte erro:
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : $F{equipamentos_codigo} at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:244) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
Porém no preview eu consigo exibir o relatório normalmente e existe outro relatório com o código idêntico a esse com algumas modificações de exibição que funciona tanto no preview quanto dentro da aplicação.
Segue o código do relatório:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.3.final using JasperReports Library version 6.4.3 -->
<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="relat_exp_mensal" language="groovy" pageWidth="900" pageHeight="792" columnWidth="860" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="df7f8bbf-2628-4ae5-bcd5-d244ebe8ed51">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Logistica_conexao"/>
<style name="Crosstab Data Text" hTextAlign="Center" hImageAlign="Center"/>
<parameter name="MES_EXPEDICAO" class="java.lang.String">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA["%"]]></defaultValueExpression>
</parameter>
<parameter name="OVERRIDE_Comparator" class="java.lang.Object" isForPrompting="false"/>
<parameter name="CODIGO_COMPARATOR" class="java.lang.Object" isForPrompting="false"/>
<queryString>
<![CDATA[SELECT
expedicao.`date_efetivada` AS expedicao_date_efetivada,
expedicao_has_equipamentos.`qtde_prevista` AS expedicao_has_equipamentos_qtde_prevista,
expedicao_has_equipamentos.`qtde_efetiva` AS expedicao_has_equipamentos_qtde_efetiva,
equipamentos.`codigo` AS equipamentos_codigo,
equipamentos.`visivel` AS equipamentos_visivel,
equipamentos.`qtde_estoque` AS equipamentos_qtde_estoque,
( SELECT
sum(distinct equipamentos.`qtde_estoque`) AS soma_equipamentos
FROM
`expedicao` expedicao
INNER JOIN
`expedicao_has_equipamentos` expedicao_has_equipamentos ON expedicao.`id` = expedicao_has_equipamentos.`expedicao_id`
INNER JOIN
`equipamentos` equipamentos ON expedicao_has_equipamentos.`equipamentos_id` = equipamentos.`id`
WHERE
equipamentos.`visivel` = true
AND expedicao.`date_efetivada` LIKE $P{MES_EXPEDICAO}
AND expedicao.status = 'Entrega') as total
FROM
`expedicao` expedicao INNER JOIN `expedicao_has_equipamentos` expedicao_has_equipamentos ON expedicao.`id` = expedicao_has_equipamentos.`expedicao_id`
INNER JOIN `equipamentos` equipamentos ON expedicao_has_equipamentos.`equipamentos_id` = equipamentos.`id`
WHERE
equipamentos.`visivel` = true
AND expedicao.`date_efetivada` LIKE $P{MES_EXPEDICAO}
AND expedicao.status = 'Entrega']]>
</queryString>
<field name="expedicao_date_efetivada" class="java.sql.Date"/>
<field name="expedicao_has_equipamentos_qtde_prevista" class="java.lang.Integer"/>
<field name="expedicao_has_equipamentos_qtde_efetiva" class="java.lang.Integer"/>
<field name="equipamentos_codigo" class="java.lang.String"/>
<field name="equipamentos_visivel" class="java.lang.Boolean"/>
<field name="equipamentos_qtde_estoque" class="java.lang.Integer"/>
<field name="total" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="250">
<elementGroup>
<crosstab>
<reportElement x="0" y="0" width="860" height="250" uuid="3609d175-b3c3-4cb7-9d89-6053c1e7766f"/>
<crosstabHeaderCell>
<cellContents>
<frame>
<reportElement style="Crosstab Data Text" x="0" y="1" width="42" height="49" uuid="da1903e9-d7ce-4670-ad6e-95b1fe4f1433"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<staticText>
<reportElement style="Crosstab Data Text" x="0" y="0" width="41" height="49" uuid="baeee394-f39a-4f13-8162-d130c1ad9821"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<text><![CDATA[Código GSUP]]></text>
</staticText>
</frame>
</cellContents>
</crosstabHeaderCell>
<rowGroup name="equipamentos_codigo" width="42" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{equipamentos_codigo}]]></bucketExpression>
<comparatorExpression><![CDATA[$P{CODIGO_COMPARATOR}]]></comparatorExpression>
</bucket>
<crosstabRowHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="0" width="42" height="17" uuid="42fb069a-32b9-457a-ae2b-a21fc7eecdaa"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{equipamentos_codigo}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement x="0" y="0" width="42" height="20" uuid="a1af5a38-b822-4504-8611-d00ac076dce5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<text><![CDATA[Total]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="expedicao_date_efetivada" height="30" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[(new SimpleDateFormat("MM/yyyy")).format($F{expedicao_date_efetivada})]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="1" y="0" width="57" height="30" uuid="786cbda8-95d6-404c-94e3-b51e4131dc58"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{expedicao_date_efetivada}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents backcolor="#005FB3" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement x="0" y="1" width="45" height="49" forecolor="#FFFFFF" uuid="06522167-c638-4b25-b8a4-bc9bc4428374"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<text><![CDATA[Total Estoque SME]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<columnGroup name="expedicao_date_efetivada1" height="20" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[(new SimpleDateFormat("dd")).format($F{expedicao_date_efetivada})]]></bucketExpression>
<comparatorExpression><![CDATA[$P{OVERRIDE_Comparator}]]></comparatorExpression>
</bucket>
<crosstabColumnHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="1" width="58" height="19" uuid="d3d7c352-4f9c-4d38-8623-f197bb922bce"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{expedicao_date_efetivada1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement x="0" y="0" width="41" height="20" uuid="a41fc777-ddfa-421c-8cb7-617684d317c6"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="false"/>
</textElement>
<text><![CDATA[Total Anual]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="expedicao_has_equipamentos_qtde_previstaMeasure" class="java.lang.Integer" calculation="Sum">
<measureExpression><![CDATA[$F{expedicao_has_equipamentos_qtde_efetiva}]]></measureExpression>
</measure>
<measure name="qtde_estoque" class="java.lang.Integer">
<measureExpression><![CDATA[$F{equipamentos_qtde_estoque}]]></measureExpression>
</measure>
<measure name="total_anual" class="java.lang.Integer" calculation="Sum">
<measureExpression><![CDATA[$F{expedicao_has_equipamentos_qtde_efetiva}]]></measureExpression>
</measure>
<measure name="total_equipamentos" class="java.lang.String">
<measureExpression><![CDATA[$F{total}]]></measureExpression>
</measure>
<crosstabCell width="58" height="17">
<cellContents>
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="0" width="58" height="17" uuid="66bae34c-24d0-462b-8273-621d13435603"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{expedicao_has_equipamentos_qtde_previstaMeasure} == null ? "0" : $V{expedicao_has_equipamentos_qtde_previstaMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="41" height="17" columnTotalGroup="expedicao_date_efetivada1">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="0" width="41" height="17" uuid="b6e7ebe7-4317-4a7e-a331-7eba86ac6c55"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{total_anual}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="45" height="17" columnTotalGroup="expedicao_date_efetivada">
<cellContents backcolor="#005FB3" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="0" width="45" height="17" uuid="e7348315-39ce-45da-be82-b105b91e13e2"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{qtde_estoque}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="58" height="20" rowTotalGroup="equipamentos_codigo">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="0" width="58" height="20" uuid="f7248148-8c6d-420e-b388-5ce72943d7f9"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{expedicao_has_equipamentos_qtde_previstaMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="41" height="20" rowTotalGroup="equipamentos_codigo" columnTotalGroup="expedicao_date_efetivada1">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="0" width="41" height="20" uuid="6cdb707c-88f8-4896-a9a4-30d3e74deec8"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{expedicao_has_equipamentos_qtde_previstaMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="45" height="20" rowTotalGroup="equipamentos_codigo" columnTotalGroup="expedicao_date_efetivada">
<cellContents backcolor="#005FB3" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Crosstab Data Text" x="0" y="0" width="45" height="20" uuid="60a5199c-5bef-4f4f-b622-bdf0a5457b2c"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$V{total_equipamentos}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</elementGroup>
</band>
</summary>
</jasperReport>