JasperReports Not Populating Data from JRBeanCollectionDataSource into Detail Band

I’m working on generating a report in JasperReports using JRBeanCollectionDataSource to pass dynamically retrieved data to my report template. The data extraction works correctly (confirmed through debugging), but the report remains blank—the Detail Band does not display any data.

JRXML report template

<!-- Created with Jaspersoft Studio version 7.0.1.final -->
<jasperReport name="TestReport" language="java"
    pageWidth="900" pageHeight="842" columnWidth="860"
    leftMargin="20" rightMargin="20" topMargin="40"
    bottomMargin="30" uuid="12345678-90ab-cdef-1234-567890abcdef">

    <!-- Define the parameter for data source -->
    <parameter name="TEST_DATA_SOURCE" class="net.sf.jasperreports.engine.JRDataSource"/>

    <!-- Define fields expected in the dataset -->
    <field name="TEST1" class="java.lang.String"/>
    <field name="TEST2" class="java.lang.String"/>
    <field name="TEST3" class="java.lang.String"/>
    <field name="TEST4" class="java.lang.String"/>
    <field name="TEST5" class="java.lang.String"/>

    <title>
        <band height="50">
            <staticText>
                <reportElement x="150" y="10" width="600" height="30"/>
                <textElement textAlignment="Center">
                    <font size="16" isBold="true"/>
                </textElement>
                <text><![CDATA[Test Report]]></text>
            </staticText>
        </band>
    </title>

    <columnHeader>
        <band height="40">
            <staticText>
                <reportElement x="0" y="0" width="172" height="30"/>
                <text><![CDATA[Test1]]></text>
            </staticText>
            <staticText>
                <reportElement x="172" y="0" width="172" height="30"/>
                <text><![CDATA[Test2]]></text>
            </staticText>
            <staticText>
                <reportElement x="344" y="0" width="172" height="30"/>
                <text><![CDATA[Test3]]></text>
            </staticText>
            <staticText>
                <reportElement x="516" y="0" width="172" height="30"/>
                <text><![CDATA[Test4]]></text>
            </staticText>
            <staticText>
                <reportElement x="688" y="0" width="172" height="30"/>
                <text><![CDATA[Test5]]></text>
            </staticText>
        </band>
    </columnHeader>

    <detail>
        <band height="30">
            <textField>
                <reportElement x="0" y="0" width="172" height="30"/>
                <textFieldExpression><![CDATA[$F{TEST1}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="172" y="0" width="172" height="30"/>
                <textFieldExpression><![CDATA[$F{TEST2}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="344" y="0" width="172" height="30"/>
                <textFieldExpression><![CDATA[$F{TEST3}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="516" y="0" width="172" height="30"/>
                <textFieldExpression><![CDATA[$F{TEST4}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="688" y="0" width="172" height="30"/>
                <textFieldExpression><![CDATA[$F{TEST5}]]></textFieldExpression>
            </textField>
        </band>
    </detail>

    <noData>
        <band height="30">
            <staticText>
                <reportElement x="0" y="0" width="860" height="20"/>
                <text><![CDATA[No Data Available]]></text>
            </staticText>
        </band>
    </noData>

</jasperReport>

JavaScript function (fillParameters()) used for data retrieval:

function fillParameters() {
    try {
        var rawData = datasourceHelper.get("testDataSource").getRows();

        if (!rawData || rawData.length === 0) {
            throwError("No data retrieved from 'testDataSource'.");
        }

        var extractedData = [];

        for (var i = 0; i < rawData.length; i++) {
            var row = rawData[i];

            var extractedRow = {
                TEST1: parseInt(row.getFieldAsString("TEST1")) || 0,
                TEST2: row.getFieldAsString("TEST2") || "",
                TEST3: row.getFieldAsString("TEST3") || "",
                TEST4: row.getFieldAsString("TEST4") || "",
                TEST5: row.getFieldAsString("TEST5") || ""
            };

            extractedData.push(extractedRow);
        }

        var JRBeanCollectionDataSource = Java.type("net.sf.jasperreports.engine.data.JRBeanCollectionDataSource");
        var jrDataSource = new JRBeanCollectionDataSource(extractedData, false);
        parameterMap.put("TEST_DATA_SOURCE", jrDataSource);

    } catch (e) {
        throwError("ERROR: " + e.message);
    }
}

What I Need Help With:

  • How can I make JasperReports recognize and iterate over TEST_DATA_SOURCE?

  • Is there a missing configuration in the JRXML template to properly bind the data?

  • Does JasperReports require an explicit connection setting for this approach?

  • Is the JRBeanCollectionDataSource being handled incorrectly in fillParameters()?

  • The data extraction works correctly (confirmed via debugging).

  • TEST_DATA_SOURCE is assigned properly.

  • The Detail Band remains empty—no data rows appear.

  • The “No Data Available” message appears, suggesting that JasperReports does not recognize the data source.