java.lang.NoSuchMethodException:类'java.lang.String'上的未知属性''

时间:2014-03-13 13:02:31

标签: java jasper-reports

我想将对象列表传递给jasper report中的list组件。我使用dataSourceExpression for list1是新的 net.sf.jasperreports.engine.data.JRBeanCollectionDataSource 和参数类是的java.util.List

当我生成报告时,它显示错误,如 java.lang.NoSuchMethodException

豆:

public void generateReport() {
    Statement stmt = null;
    ResultSet resultset = null;
    ResultSet resultset1 = null;
    Connection con = null;
    String fromdate = "2013-01-01";
    String todate = "2013-01-31";
    int unitId = 1;
    String driver = "com.mysql.jdbc.Driver";
    String connection = "jdbc:mysql://localhost:3306/compliance?user=root&password=root";
    List<Object> shortnamelist = new ArrayList<Object>();
    try {
        String selectstatement = "CALL P_Select_Salary ('" + fromdate + "',  '" + todate + "','" + unitId + "', 'Salary_Summary')";
        Class.forName(driver);
        con = DriverManager.getConnection(connection);
        stmt = con.createStatement();
        resultset = stmt.executeQuery(selectstatement);
        JRResultSetDataSource resultsetdatasource = new JRResultSetDataSource(resultset);

        String selectstatement1 = "CALL P_Select_Salary ('2013-01-01', '2013-01-31', 1, 'Salary_OA')";
        Class.forName(driver);
        con = DriverManager.getConnection(connection);
        stmt = con.createStatement();
        resultset1 = stmt.executeQuery(selectstatement1);
        while (resultset1.next()) {
            String shortname = resultset1.getString("alw_short_name");
            logger.info("shortname" + shortname);
            String workamount = resultset1.getString("Work_amt");
            logger.info("workamount" + workamount);
            shortnamelist.add(shortname);
            shortnamelist.add(workamount);
        }
        logger.info("shortnamelist" + shortnamelist.size());
        Map<String, Object> hashmap = new HashMap<String, Object>();
        hashmap.put("list1", shortnamelist);
        String realpath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("common/reports/registerofwages.jasper");
        jasperprint = JasperFillManager.fillReport(realpath, hashmap, resultsetdatasource);
        HttpServletResponse httpservlet = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
        httpservlet.addHeader("Content-disposition", "attachment;filename=wageslip.pdf");

        try {
            JasperExportManager.exportReportToPdfStream(jasperprint, httpservlet.getOutputStream());
        } catch (JRException ex) {
            ex.getMessage();
        } finally {
            FacesContext.getCurrentInstance().responseComplete();
        }
    } catch (net.sf.jasperreports.engine.JRException JRexception) {
        logger.info("JRException Exception" + JRexception.getMessage());
        JsfUtil.addErrorMessage("No Datas between FromDate to ToDate");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        close(stmt);
        close(resultset);
        close(con);
    }
}

jrxml

      <?xml version="1.0" encoding="UTF-8"?>
      <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="registerofwages" pageWidth="1008" pageHeight="605" orientation="Landscape" columnWidth="968" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6847ece9-3089-436e-bb14-8cbbfebd57a9">
<subDataset name="dataset2" uuid="1f620401-64dd-42eb-8f05-e40424b866bc">
    <queryString language="plsql">
        <![CDATA[]]>
    </queryString>
    <field name="alw_short_name" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Work_amt" class="java.lang.String">
        <fieldDescription><![CDATA[(daily -> workday*day_Amount), (monthly --> Salary - lop_Amt)]]></fieldDescription>
    </field>
    <variable name="shortname" class="java.lang.String">
        <variableExpression><![CDATA[$F{alw_short_name}+"="+$F{Work_amt}+","]]></variableExpression>
    </variable>
</subDataset>
<parameter name="list1" class="java.util.List">
    <defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString language="plsql">
    <![CDATA[CALL P_Select_Salary ('2013-01-01', '2013-01-31', 1, 'Salary_Summary')]]>
</queryString>
<field name="unit_id" class="java.lang.Integer"/>
<field name="Category_Code" class="java.lang.Integer"/>
<field name="FromDate" class="java.sql.Date"/>
<field name="ToDate" class="java.sql.Date"/>
<field name="emp_id" class="java.lang.String"/>
<field name="Emp_Class" class="java.lang.String"/>
<field name="Gender" class="java.lang.String"/>
<field name="Work_Hrs" class="java.lang.String"/>
<field name="AB_Hrs" class="java.lang.String"/>
<field name="LOP_Hrs" class="java.lang.String"/>
<field name="Paid_Leave_Hrs" class="java.lang.String"/>
<field name="OT_Hrs" class="java.lang.String"/>
<field name="WO" class="java.lang.String"/>
<field name="NFH" class="java.lang.String"/>
<field name="CO_WO" class="java.lang.String"/>
<field name="CO_NFH" class="java.lang.String"/>
<field name="Pay_NFH" class="java.lang.String"/>
<field name="BASIC_F" class="java.lang.String"/>
<field name="DA_F" class="java.lang.String"/>
<field name="SA_F" class="java.lang.String"/>
<field name="Basic_E" class="java.lang.String"/>
<field name="DA_E" class="java.lang.String"/>
<field name="SA_E" class="java.lang.String"/>
<field name="DY_Alw_E" class="java.lang.String"/>
<field name="NFH_E" class="java.lang.String"/>
<field name="Paid_Leave_E" class="java.lang.String"/>
<field name="LOP_Amt" class="java.lang.String"/>
<field name="OT_Amt" class="java.lang.String"/>
<field name="Gross_Amt" class="java.lang.String"/>
<field name="ESI_F" class="java.lang.String"/>
<field name="ESI_Amt" class="java.lang.String"/>
<field name="Emp_ESI" class="java.lang.String"/>
<field name="Emr_ESI" class="java.lang.String"/>
<field name="EPF_F" class="java.lang.String"/>
<field name="EPF_Amt" class="java.lang.String"/>
<field name="PF" class="java.lang.String"/>
<field name="EPS" class="java.lang.String"/>
<field name="EPF" class="java.lang.String"/>
<field name="Advance_Loan" class="java.lang.String"/>
<field name="Fine" class="java.lang.String"/>
<field name="Damage_Loss" class="java.lang.String"/>
<field name="Other_Deduct" class="java.lang.String"/>
<field name="Net_Salary" class="java.lang.String"/>
<field name="Accum_unpaid_Amt" class="java.lang.String"/>
<field name="Paid_Date" class="java.lang.String"/>
<field name="Paid_Amt" class="java.lang.String"/>
<variable name="EarnedDays" class="java.lang.Double">
    <variableExpression><![CDATA[(Double.valueOf($F{Work_Hrs})+Double.valueOf($F{Paid_Leave_Hrs})+Double.valueOf($F{NFH})-Double.valueOf($F{CO_WO})-Double.valueOf($F{CO_NFH}))/8]]></variableExpression>
</variable>
<variable name="LOP" class="java.lang.Double">
    <variableExpression><![CDATA[(Double.valueOf($F{AB_Hrs})+Double.valueOf($F{LOP_Hrs}))/8]]></variableExpression>
</variable>
<variable name="UnitsofWork" class="java.lang.Double">
    <variableExpression><![CDATA[Double.valueOf($F{Work_Hrs})/8]]></variableExpression>
</variable>
<variable name="DailyRate" class="java.lang.Double">
    <variableExpression><![CDATA[Double.valueOf($F{BASIC_F})+Double.valueOf($F{DA_F})+Double.valueOf($F{SA_F})]]></variableExpression>
</variable>
<variable name="OtherAllowance" class="java.lang.Double">
    <variableExpression><![CDATA[Double.valueOf($F{SA_E})+Double.valueOf($F{DY_Alw_E})]]></variableExpression>
</variable>
<variable name="variable1" class="java.lang.String"/>
<variable name="OtherDeduction" class="java.lang.Double">
    <variableExpression><![CDATA[Double.valueOf($F{Other_Deduct})+Double.valueOf($F{Damage_Loss})+Double.valueOf($F{Advance_Loan})]]></variableExpression>
</variable>
<variable name="NetPay" class="java.lang.Double">
    <variableExpression><![CDATA[Double.valueOf($F{Net_Salary})+Double.valueOf($F{Accum_unpaid_Amt})]]></variableExpression>
</variable>
<variable name="emp" class="java.lang.String">
    <variableExpression><![CDATA[$F{emp_id}]]></variableExpression>
</variable>
<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band height="34" splitType="Stretch"/>
</title>
<detail>
    <band height="26" splitType="Stretch">
        <rectangle>
            <reportElement x="0" y="0" width="968" height="21" uuid="daa5c891-0775-4741-9887-b19d8beda0f3"/>
            <graphicElement>
                <pen lineWidth="0.75"/>
            </graphicElement>
        </rectangle>
        <textField>
            <reportElement x="483" y="0" width="41" height="10" uuid="a36c4a26-7e14-4da1-9d1a-b83c173875b4"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{Basic_E}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="763" y="0" width="25" height="10" uuid="e449b874-a745-468c-89f0-f10b1bd4b7f9"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{Emp_ESI}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="828" y="0" width="29" height="10" uuid="802a4c2e-684c-478f-99ec-31100ea47f70"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{Fine}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="524" y="0" width="41" height="10" uuid="0df3e708-23ba-47f8-b8d6-f3d9b3d6ccd0"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{DA_E}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="805" y="11" width="55" height="10" uuid="60340cc0-0348-44b4-a1d5-7f91a978c17b"/>
            <textElement verticalAlignment="Top">
                <font fontName="Times New Roman" size="8" isBold="false"/>
            </textElement>
            <text><![CDATA[Pre. Unpaid Amt]]></text>
        </staticText>
        <textField pattern="###0.00">
            <reportElement x="410" y="0" width="35" height="10" uuid="63e0bc64-4313-4bfb-988b-10925ab7fd22"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{DailyRate}]]></textFieldExpression>
        </textField>
        <textField pattern="###0.00">
            <reportElement mode="Opaque" x="565" y="0" width="41" height="10" uuid="bc821e4a-21ed-42b1-a825-8b450b3df0d7"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{OtherAllowance}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="445" y="0" width="38" height="10" uuid="974eaf1e-85f1-48f7-8e0a-0285522500cc"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{OT_Hrs}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="860" y="11" width="41" height="10" uuid="4580b599-a7d8-430b-b4fb-817be05d7852"/>
            <textElement textAlignment="Center">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{Accum_unpaid_Amt}]]></textFieldExpression>
        </textField>
        <textField pattern="###0.00">
            <reportElement x="857" y="0" width="42" height="10" uuid="3f2ddae9-0719-4a3e-96ad-64355f6ae071"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{NetPay}]]></textFieldExpression>
        </textField>
        <line>
            <reportElement x="1" y="10" width="898" height="1" uuid="6d8df80d-8aa0-4225-b032-75b264cc7714"/>
            <graphicElement>
                <pen lineWidth="0.25"/>
            </graphicElement>
        </line>
        <line>
            <reportElement x="900" y="0" width="1" height="21" uuid="d0cf6726-f104-4d9f-9364-2470494bd3f7"/>
            <graphicElement>
                <pen lineWidth="0.5"/>
            </graphicElement>
        </line>
        <textField pattern="###0.00">
            <reportElement x="788" y="0" width="40" height="10" uuid="4a70eb04-8dd0-456b-993f-47fece07c2bf"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{OtherDeduction}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="734" y="0" width="29" height="10" uuid="eb856a9a-daaa-4fe8-b9b3-a3a0908dccf4"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{PF}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="688" y="0" width="46" height="10" uuid="e67974c7-25a4-4b1c-aac3-363d034ed582"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{Gross_Amt}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="648" y="0" width="40" height="10" uuid="e4fdbff5-68fe-4024-8823-28b49f299884"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{Paid_Leave_E}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="606" y="0" width="42" height="10" uuid="ed79fd25-fdc2-4e15-971b-2c7185a46737"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{OT_Amt}]]></textFieldExpression>
        </textField>
        <textField pattern="###0.00">
            <reportElement x="383" y="0" width="27" height="10" uuid="4280ee9f-bf59-4c70-9969-0b0363d6e110"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{UnitsofWork}]]></textFieldExpression>
        </textField>
        <textField pattern="###0.00">
            <reportElement x="345" y="0" width="38" height="10" uuid="d219ec9b-c100-4a73-bec1-216e9b99ebac"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{LOP}]]></textFieldExpression>
        </textField>
        <textField pattern="###0.00">
            <reportElement x="306" y="0" width="39" height="10" uuid="9dfd193e-5e41-43c1-bf0e-f6712aca2f20"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{EarnedDays}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="164" y="0" width="15" height="10" uuid="6cc74bcd-3383-47ca-8786-a9a68a159bfc"/>
            <box>
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center" verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[((Integer.valueOf($F{Gender})== 1)? "M" : "F")]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="24" y="0" width="66" height="10" uuid="2a2f4987-8efa-4a3e-a537-1ba41126df0a"/>
            <textElement verticalAlignment="Bottom">
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{emp_id}]]></textFieldExpression>
        </textField>
        <componentElement>
            <reportElement x="2" y="11" width="803" height="10" uuid="bf6f9ced-37c6-4c87-b7b3-879cb7cb386a"/>
            <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal" ignoreWidth="true">
                <datasetRun subDataset="dataset2" uuid="08b6f257-2a35-4041-a1bd-d5186d2c5a34">
                    <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{list1})]]></dataSourceExpression>
                </datasetRun>
                <jr:listContents height="10" width="150">
                    <textField>
                        <reportElement x="0" y="0" width="52" height="10" uuid="d017a7a8-504a-4483-9ef2-81f6de500155"/>
                        <textElement>
                            <font fontName="Times New Roman" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{alw_short_name}]]></textFieldExpression>
                    </textField>
                    <textField>
                        <reportElement x="68" y="0" width="50" height="10" uuid="e46db97e-3dd6-4b94-b030-e4cf8a473848"/>
                        <textElement>
                            <font fontName="Times New Roman" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{Work_amt}]]></textFieldExpression>
                    </textField>
                </jr:listContents>
            </jr:list>
        </componentElement>
        <textField>
            <reportElement x="0" y="0" width="22" height="10" uuid="dfffa32c-a2a8-403e-8b25-6ec49e378493"/>
            <textElement>
                <font fontName="Times New Roman" size="8"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
        </textField>
    </band>
</detail>
<columnFooter>
    <band height="21">
        <staticText>
            <reportElement x="508" y="0" width="100" height="20" uuid="507050a7-1b44-4756-a491-8056a027243c"/>
            <text><![CDATA[Sub Total]]></text>
        </staticText>
    </band>
</columnFooter>
<pageFooter>
    <band height="21" splitType="Stretch">
        <textField>
            <reportElement x="439" y="0" width="100" height="20" uuid="cfbb544e-3e85-4845-9043-8d7ae6201d28"/>
            <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
    </band>
</pageFooter>
      </jasperReport>

堆栈追踪:

      net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : 
at net.sf.jasperreports.components.list.HorizontalFillList.prepare(HorizontalFillList.java:254)
at net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(JRFillComponentElement.java:129)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:328)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:392)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:351)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2039)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:281)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:144)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:891)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:823)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:88)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:653)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:569)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:915)
at com.p41.reports.RegisterofWages.generateReport(RegisterofWages.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.p41.setting.FacesFilter.doFilter(FacesFilter.java:145)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
    Caused by: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : 
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:123)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:96)
at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:100)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1317)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1218)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1194)
at net.sf.jasperreports.components.list.FillDatasetRun.next(FillDatasetRun.java:168)
at net.sf.jasperreports.components.list.HorizontalFillList.prepare(HorizontalFillList.java:136)
... 53 more
    Caused by: java.lang.NoSuchMethodException: Unknown property '' on class 'class java.lang.String'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1313)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:111)

5 个答案:

答案 0 :(得分:23)

我觉得这个很旧,但是,对于下一个寻找它的人来说......

Jasper Studio和ireport有时会为字段创建空白描述:

<fieldDescription><![CDATA[]]></fieldDescription>

删除这些,您应该停止收到此错误。

另见:https://community.jaspersoft.com/questions/527187/nosuchmethodexception-unknown-property

答案 1 :(得分:0)

Yonatan的答案对我有用!!!,在字段中

<fieldDescription><![CDATA[]]></fieldDescription>

我像这样更改JPA中的attributo

<fieldDescription><![CDATA[someColumn]]></fieldDescription>

someColumn提供JPA Objecte包含的属性,在设计更改后尝试报告并运行。 在java代码中,我构建一个只包含打印对象的List:

List<Producto> toPrint = new Stack<>();
    toPrint.add(selected);
    JRBeanCollectionDataSource  beanCollectionDataSource = new JRBeanCollectionDataSource(toPrint);

为我工作更改JPA对象包含的属性的空字段。

答案 2 :(得分:0)

对我来说,只需将false传递给JRBeanCollectionDataSource(isUseFieldDescription)的第二个参数即可解决我的问题。

new JRBeanCollectionDataSource(collection, false);

答案 3 :(得分:0)

这适合我。

  • 如果您在报告字段中添加了空格,请删除空格。
  • 像这样添加false。

    JRDataSource JRdataSource = new JRBeanCollectionDataSource(/*your data's*/, false);
    

答案 4 :(得分:0)

检查您的吸气剂和吸气剂。命名不当可能会引起我的问​​题。