Search code examples
jasper-reportssubreportjaspersoft-studio

Subreport with return value gives exception "System is not facet valid with enumeration"


I'm getting an exception during compile in Jaspersoft Studio 6.4.0. How do I address this?

I've created a report containing a subreport from which I want to return a value. To do that, I have:

  1. Created a variable in the subreport called, "logTotal", set to the value of another variable, which is a summation calculated in the report. No reset type, no calculation function.
  2. Created a variable in the main report with the same name and type. No reset type, no calculation function.
  3. In the main report, created a subreport return value link between the two variables with calculation type, "System."

On compile, I'm seeing the following exception:

net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException; lineNumber: 454; columnNumber: 91; cvc-enumeration-valid: 
Value 'System' is not facet-valid with respect to enumeration '[Nothing, Count, DistinctCount, Sum, Average, Lowest, Highest, StandardDeviation, Variance, First]'. It must be a value from the enumeration.

I can choose the "System" choice from a If I use other choices ("No calculation function," "First," "Average," etc.), the subreport returns null.

Main Report:

<variable name="logTotal" class="java.math.BigDecimal" resetType="None"/>
...
<subreport>
    <reportElement positionType="Float" x="0" y="60" width="572" height="40" uuid="d3ec84fb-528f-41f5-8b54-26112fd95b50"/>
    <subreportParameter name="loadList">
        <subreportParameterExpression><![CDATA[$P{loadList}]]></subreportParameterExpression>
    </subreportParameter>
    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
    <returnValue subreportVariable="logTotal" toVariable="logTotal" calculation="System"/>
    <subreportExpression><![CDATA["scaling/reports/ScaleSummary_Logs.jasper"]]></subreportExpression>
</subreport>

Subreport:

<variable name="price4" class="java.math.BigDecimal" calculation="Sum">
    <variableExpression><![CDATA[$F{price}]]></variableExpression>
</variable>
<variable name="logTotal" class="java.math.BigDecimal" resetType="None">
    <variableExpression><![CDATA[$V{price4}]]></variableExpression>
</variable>

Solution

  • It seems that the exception is the result of a mismatch between what JS Studio permits and what this particular compiler (not sure whether JSS uses the compiler I installed (6.4.1) or one that it installs) allows.

    Obviously, the solution is to ensure that the compiler being used is compatible.