Exception throws, unable to identified field name from bean,
JRXML file Created with Jaspersoft Studio version 6.2.2
<queryString>
<![CDATA[]]>
</queryString>
<field name="barcodeNo" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="28" splitType="Stretch">
<componentElement>
<reportElement x="0" y="11" width="85" height="17" uuid="dd489dd8-2c98-4aa0-9424-8f657197b22c"/>
<jr:barbecue xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" type="Code128" drawText="true" checksumRequired="false">
<jr:codeExpression><![CDATA[$F{barcodeNo}]]></jr:codeExpression>
</jr:barbecue>
</componentElement>
<textField>
<reportElement x="20" y="1" width="30" height="9" uuid="071ed7be-b4b9-4e60-8aea-0c9bb6cd55fe"/>
<textElement>
<font size="4"/>
</textElement>
<textFieldExpression><![CDATA[$F{barcodeNo}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
From java service
List<String> barcodeList = getBarcodesFromRange(startBarcode, endBarcode);
Map<String, Object> parametersMap = new HashMap<>();
JasperReport jasperReport = JasperCompileManager.compileReport(resource.getInputStream());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parametersMap, getDataSource());
return jasperPrint;
}
private static JRDataSource getDataSource() {
Collection<BarcodePrint> coll = new ArrayList<>();
coll.add(new BarcodePrint("1234","3333"));
coll.add(new BarcodePrint("1111","3333"));
return new JRBeanCollectionDataSource(coll);
Bean for fill data
public class BarcodePrint{
String barcodeNo;
String desc;
public BarcodePrint(String barcodeNo, String desc) {
this.barcodeNo = barcodeNo;
this.desc = desc;
}
public String getBarcodeNo() {
return barcodeNo;
}
public void setBarcodeNo(String barcodeNo) {
this.barcodeNo = barcodeNo;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
Getting exception,
Caused by: java.lang.NoSuchMethodException: Unknown property '' on class 'class com.int99.pos9.domain.BarcodePrint'
Just change the following line of code, done the trick for me
` return new JRBeanCollectionDataSource(coll,false);`