我收到了标题中提到的错误消息。我尝试了在不同论坛中找到的所有内容,但没有任何效果。
这是我的Bean类:
public class NameBean {
private String reportName, shortDescription, description;
public NameBean(String reportName, String shortDescription, String description) {
this.reportName = reportName;
this.shortDescription = shortDescription;
this.description = description;
}
public String getName(){
return reportName;
}
public String getShortDescription() {
return shortDescription;
}
public String getDescription() {
return description;
}
public void setName(String reportName){
this.reportName = reportName;
}
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
public void setDescription(String description) {
this.description = description;
}
}
这是工厂类:
public class TestFactory {
public static ArrayList generateCollection() {
ArrayList collection = new ArrayList();
collection.add(new NameBean("PS_TF_VSGM-A-2535_01", "Automatisches Starten der Online-Prüfung und -Aktualisierung",
"Der Konfigurationsparameter zur Online-Prüfung und -Aktualisierung(MODE_ONLINE_CHECK) ist auf den Wert First konfiguriert. Es wird eine eGK in das Kartenterminal des Konnektorsimulators gesteckt für die im laufenden Quartalnoch keine Online-Prüfung durchgeführt wurde."));
collection.add(new EntranceValuesBean("eingeschaltet", "online", "Ohne TLS", "Standard (PTV 1.6.0)", "Mandat > Terminal > Karte"));
return collection;
}
}
这是我的XML
<?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="test" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2f6e4db4-9f8f-4ffe-9759-6e1fd142f492">
<property name="template.type" value="columnar"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="src/dataset1.xml"/>
<style name="Title" forecolor="#000000" fontName="Times New Roman" fontSize="50" isBold="false"/>
<style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18" isBold="false"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#F0EFEF"/>
</conditionalStyle>
</style>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="description" class="java.lang.String">
<fieldDescription><![CDATA[description]]></fieldDescription>
</field>
<field name="shortDescription" class="java.lang.String">
<fieldDescription><![CDATA[shortDescription]]></fieldDescription>
</field>
<title>
<band height="290" splitType="Stretch">
<staticText>
<reportElement style="Title" x="0" y="0" width="400" height="30" uuid="756c5f0f-cbe1-46b1-9f5a-645caa1a189e"/>
<textElement>
<font size="16" isBold="false"/>
</textElement>
<text><![CDATA[Konnektorsimmulator Testfall Protokoll: ]]></text>
</staticText>
<line>
<reportElement positionType="FixRelativeToBottom" x="-20" y="80" width="551" height="1" uuid="5e41185f-9c90-45ca-839b-e28b308c1430"/>
</line>
</band>
</title>
<detail>
<band height="91" splitType="Stretch"/>
</detail>
</jasperReport>
这就是我得到的错误:
net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean: name.
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: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean: name.
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:134)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:99)
at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:104)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1373)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1274)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1250)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1056)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:117)
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)
Caused by: java.lang.NoSuchMethodException: Unknown property 'name' on class 'class EntranceValuesBean'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1277)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:808)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:884)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:464)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:114)
... 10 more
我完全不知道如何解决这个问题。
答案 0 :(得分:0)
从堆栈跟踪
Caused by: java.lang.NoSuchMethodException: Unknown property 'name' on class 'class EntranceValuesBean'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1277)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:808)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:884)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:464)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:114)
问题似乎是由于 EntranceValuesBean 类。 检查该类是否在该类中具有名为 getName 的getter方法。
答案 1 :(得分:0)
感谢您对类EntranceValuesBean的建议。我删除了它并将代码写入NameBean类。它现在正在运作。