Why am I getting an "Error retrieving field value from bean", "Caused by Unknown Property on class"

0
Hello everyone, this is my first time posting here.
 
I have a jasper report template jrxml that I am trying to fill with the information from a specific JavaBean class.
 
This class doubles as an entity for the Java Persistence API (JPA ) and thus maps directly to a database.
 
Here is my Bean class:
 
package main.java.gls.entities;
 
import main.java.gls.entities.util.JobAmount;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
 
@Entity
@Table(name = "job")
@NamedQueries(
{
    @NamedQuery(name = "Job.findAll", query = "SELECT j FROM Job j"),
    @NamedQuery(name = "Job.findByJobNum", query = "SELECT j FROM Job j WHERE j.JobPK.jobNum = :jobNum"),
    @NamedQuery(name = "Job.findByRev", query = "SELECT j FROM Job j WHERE j.JobPK.rev = :rev"),
    @NamedQuery(name = "Job.findByLastUpd", query = "SELECT j FROM Job j WHERE j.lastUpd = :lastUpd"),
    @NamedQuery(name = "Job.findByFCompDate", query = "SELECT j FROM Job j WHERE j.fCompDate = :fCompDate"),
    @NamedQuery(name = "Job.findByCCompDate", query = "SELECT j FROM Job j WHERE j.cCompDate = :cCompDate"),
    @NamedQuery(name = "Job.findByEntDate", query = "SELECT j FROM Job j WHERE j.entDate = :entDate"),
    @NamedQuery(name = "Job.findByFieldDate", query = "SELECT j FROM Job j WHERE j.fieldDate = :fieldDate"),
    @NamedQuery(name = "Job.findByFinDate", query = "SELECT j FROM Job j WHERE j.finDate = :finDate"),
    @NamedQuery(name = "Job.findByDueDate", query = "SELECT j FROM Job j WHERE j.dueDate = :dueDate"),
    @NamedQuery(name = "Job.findByJobIsRush", query = "SELECT j FROM Job j WHERE j.jobIsRush = :jobIsRush"),
    @NamedQuery(name = "Job.findByComRes", query = "SELECT j FROM Job j WHERE j.comRes = :comRes"),
    @NamedQuery(name = "Job.findByPltBk", query = "SELECT j FROM Job j WHERE j.pltBk = :pltBk"),
    @NamedQuery(name = "Job.findByPltPg", query = "SELECT j FROM Job j WHERE j.pltPg = :pltPg"),
    @NamedQuery(name = "Job.findByDeedBk", query = "SELECT j FROM Job j WHERE j.deedBk = :deedBk"),
    @NamedQuery(name = "Job.findByDeedPg", query = "SELECT j FROM Job j WHERE j.deedPg = :deedPg"),
    @NamedQuery(name = "Job.findByLandLot", query = "SELECT j FROM Job j WHERE j.landLot = :landLot"),
    @NamedQuery(name = "Job.findByDistrict", query = "SELECT j FROM Job j WHERE j.district = :district"),
    @NamedQuery(name = "Job.findBySection", query = "SELECT j FROM Job j WHERE j.section = :section"),
    @NamedQuery(name = "Job.findByLot", query = "SELECT j FROM Job j WHERE j.lot = :lot"),
    @NamedQuery(name = "Job.findByBlock", query = "SELECT j FROM Job j WHERE j.block = :block"),
    @NamedQuery(name = "Job.findByUnit", query = "SELECT j FROM Job j WHERE j.unit = :unit"),
    @NamedQuery(name = "Job.findByPhase", query = "SELECT j FROM Job j WHERE j.phase = :phase"),
    @NamedQuery(name = "Job.findBySubDiv", query = "SELECT j FROM Job j WHERE j.subDiv = :subDiv"),
    @NamedQuery(name = "Job.findBySubSec", query = "SELECT j FROM Job j WHERE j.subSec = :subSec"),
    @NamedQuery(name = "Job.findByParIdNum", query = "SELECT j FROM Job j WHERE j.parIdNum = :parIdNum"),
    @NamedQuery(name = "Job.findByStreetNum", query = "SELECT j FROM Job j WHERE j.streetNum = :streetNum"),
    @NamedQuery(name = "Job.findByStreetNumAlt", query = "SELECT j FROM Job j WHERE j.streetNumAlt = :streetNumAlt"),
    @NamedQuery(name = "Job.findByStreetName", query = "SELECT j FROM Job j WHERE j.streetName = :streetName"),
    @NamedQuery(name = "Job.findByCity", query = "SELECT j FROM Job j WHERE j.city = :city"),
    @NamedQuery(name = "Job.findByState", query = "SELECT j FROM Job j WHERE j.state = :state"),
    @NamedQuery(name = "Job.findByZipCode", query = "SELECT j FROM Job j WHERE j.zipCode = :zipCode"),
    @NamedQuery(name = "Job.findByOrderDate", query = "SELECT j FROM Job j WHERE j.orderDate = :orderDate"),
    @NamedQuery(name = "Job.findByAmtBill", query = "SELECT j FROM Job j WHERE j.amtBill = :amtBill"),
    @NamedQuery(name = "Job.findByAmtPaid", query = "SELECT j FROM Job j WHERE j.amtPaid = :amtPaid"),
    @NamedQuery(name = "Job.findByOldClientNum", query = "SELECT j FROM Job j WHERE j.oldClientNum = :oldClientNum"),
    @NamedQuery(name = "Job.findByOldClientAlpha", query = "SELECT j FROM Job j WHERE j.oldClientAlpha = :oldClientAlpha"),
    @NamedQuery(name = "Job.findByChkSum", query = "SELECT j FROM Job j WHERE j.chkSum = :chkSum")
})
public class Job implements Serializable
{
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected JobPK JobPK;
    @Column(name = "AddInfo")
    private String addInfo;
 
    public Job ()
    {
    }
 
    public Job ( JobPK jobPK )
    {
        this.JobPK = jobPK;
    }
 
    public Job ( int jobNum, int rev )
    {
        this.JobPK = new JobPK(jobNum, rev);
    }
 
    public JobPK getJobPK ()
    {
        return JobPK;
    }
 
    public void setJobPK ( JobPK jobPK )
    {
        this.JobPK = jobPK;
    }
 
    public String getAddInfo ()
    {
        return addInfo;
    }
 
    public void setAddInfo ( String addInfo )
    {
        this.addInfo = addInfo;
    }
 
    @Override
    public int hashCode ()
    {
        int hash = 0;
        hash += (JobPK != null ? JobPK.hashCode() : 0);
        return hash;
    }
 
    @Override
    public boolean equals ( Object object )
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if ( !(object instanceof Job) )
        {
            return false;
        }
        
        Job other = ( Job ) object;
        
        if ( ( this.JobPK == null && other.JobPK != null )
                ||  ( this.JobPK != null && !this.JobPK.equals(other.JobPK) ) )
        {
            return false;
        }
        return true;
    }
 
    @Override
    public String toString ()
    {
        return "gls.entities.Job[ JobPK=" + JobPK + " ]";
    }
 
    
    public boolean hasBalance(){
        if (getAmtDue().equals(JobAmount.zero)){
            return false;
        } else {
            return true;
        }
    }
    
    
    //total amount of applied payments.
    public BigDecimal getAmtApplied() {
        return JobAmount.getAmountApplied(this);
    }
    
    
    //amount billed minus amount applied.
    public BigDecimal getAmtDue() {
        return JobAmount.getAmountDue(this);
    }
}
 
 
My JRXML looks like this:
<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1  --><!-- 2017-05-01T09:16:14 --><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="testInvoice_2" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4eedbb89-b4f6-4469-9ab6-f642a1688cf7"> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test JOB Database"/> <style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/> <style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/> <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="#EEEFF0"/>  </conditionalStyle> </style> <style name="Table">  <box>   <pen lineWidth="1.0" lineColor="#000000"/>   <topPen lineWidth="1.0" lineColor="#000000"/>   <leftPen lineWidth="1.0" lineColor="#000000"/>   <bottomPen lineWidth="1.0" lineColor="#000000"/>   <rightPen lineWidth="1.0" lineColor="#000000"/>  </box> </style> <style name="Table_TH" mode="Opaque" backcolor="#FFFFFF">  <box>   <pen lineWidth="0.5" lineColor="#000000"/>   <topPen lineWidth="0.5" lineColor="#000000"/>   <leftPen lineWidth="0.5" lineColor="#000000"/>   <bottomPen lineWidth="0.5" lineColor="#000000"/>   <rightPen lineWidth="0.5" lineColor="#000000"/>  </box> </style> <style name="Table_CH" mode="Opaque" backcolor="#CACED0">  <box>   <pen lineWidth="0.5" lineColor="#000000"/>   <topPen lineWidth="0.5" lineColor="#000000"/>   <leftPen lineWidth="0.5" lineColor="#000000"/>   <bottomPen lineWidth="0.5" lineColor="#000000"/>   <rightPen lineWidth="0.5" lineColor="#000000"/>  </box> </style> <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">  <box>   <pen lineWidth="0.5" lineColor="#000000"/>   <topPen lineWidth="0.5" lineColor="#000000"/>   <leftPen lineWidth="0.5" lineColor="#000000"/>   <bottomPen lineWidth="0.5" lineColor="#000000"/>   <rightPen lineWidth="0.5" lineColor="#000000"/>  </box>  <conditionalStyle>   <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>   <style backcolor="#D8D8D8"/>  </conditionalStyle> </style> <field name="addInfo" class="java.lang.String"/> <field name="JobPK" class="main.java.gls.entities.JobPK">  <fieldDescription><![CDATA[JobPK]]></fieldDescription> </field> <columnHeader>  <band height="57">   <staticText>    <reportElement x="20" y="10" width="100" height="30" uuid="ce227a04-2d3c-41eb-a9a4-f8502249ba54"/>    <textElement>     <font fontName="SansSerif"/>    </textElement>    <text><![CDATA[Job Number:]]></text>   </staticText>  </band> </columnHeader> <detail>  <band height="117">   <staticText>    <reportElement x="20" y="27" width="100" height="30" uuid="ac395cac-88c5-4702-b0dd-d1cedad753d0"/>    <text><![CDATA[Amount Billed:]]></text>   </staticText>   <staticText>    <reportElement stretchType="ContainerBottom" x="23" y="90" width="75" height="20" uuid="5f2f6ac8-32d4-42df-a6fc-d78e0fd6a73a"/>    <text><![CDATA[INFO]]></text>   </staticText>  </band> </detail> <lastPageFooter>  <band height="177">   <staticText>    <reportElement positionType="Float" x="-1" y="30" width="261" height="101" uuid="1a0d7088-5af7-4865-8be1-41ec5f51fb36"/>    <box>     <topPen lineWidth="1.1" lineStyle="Dashed"/>     <leftPen lineWidth="1.1" lineStyle="Dashed"/>     <bottomPen lineWidth="1.1" lineStyle="Dashed"/>     <rightPen lineWidth="1.1" lineStyle="Dashed"/>    </box>    <text><![CDATA[Your notes here]]></text>   </staticText>   <staticText>    <reportElement positionType="Float" mode="Opaque" x="0" y="147" width="556" height="30" backcolor="#E6E8E9" uuid="36aa233d-4305-48e6-974a-1bbf89bb3c8f"/>    <textElement textAlignment="Center" verticalAlignment="Middle">     <font fontName="Serif" size="9" isItalic="true"/>    </textElement>    <text><![CDATA[THANKYOU FOR YOUR BUSINESS]]></text>   </staticText>  </band> </lastPageFooter></jasperReport>
I saw this post: http://community.jaspersoft.com/questions/527187/nosuchmethodexception-u... and have tried all of the possible solutions that I have found in this and other posts/articles, but I still can't seem to figure out what's going on, whener I run my application I get the following error:
Filling report: C:\Users\bsnider\JaspersoftWorkspace\LisaPro Reports\testInvoice
.jasper
net.sf.jasperreports.engine.JRException: Error retrieving field value from bean:
JobPK.
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProp
erty(JRAbstractBeanDataSource.java:193)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldVal
ue(JRAbstractBeanDataSource.java:158)
at net.sf.jasperreports.engine.data.JRBeanArrayDataSource.getFieldValue(
JRBeanArrayDataSource.java:90)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDat
aset.java:1489)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.jav
a:1390)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.jav
a:1366)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:
1085)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVertic
alFiller.java:113)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:
582)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFill
er.java:414)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:121)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.
java:583)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillMa
nager.java:929)
at main.java.gls_desktop.jasperreports.JReportFiller.FillReport(JReportF
iller.java:82)
at main.java.gls_desktop.jasperreports.JReportFiller.FillReport(JReportF
iller.java:61)
at main.java.gls_desktop.jasperreports.JasperReportsTestFile.<init>(Jasp
erReportsTestFile.java:42)
at main.java.gls_desktop.jasperreports.AlternateMainJasperReportsTest.ma
in(AlternateMainJasperReportsTest.java:15)
at main.java.gls_desktop.GLSapp.main(GLSapp.java:132)
Caused by: java.lang.NoSuchMethodException: Unknown property 'JobPK' on class 'c
lass main.java.gls.entities.Job'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(Prop
ertyUtilsBean.java:1277)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(Prop
ertyUtilsBean.java:808)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUt
ilsBean.java:884)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.
java:464)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProp
erty(JRAbstractBeanDataSource.java:173)
... 17 more
java.lang.NoSuchMethodException: Unknown property 'JobPK' on class 'class main.j
ava.gls.entities.Job'
Failed To Fill Report
java.lang.NullPointerException
at net.sf.jasperreports.engine.JasperPrintManager.print(JasperPrintManag
er.java:129)
at net.sf.jasperreports.engine.JasperPrintManager.printReport(JasperPrin
tManager.java:326)
at main.java.gls_desktop.jasperreports.JReportPrinter.Print(JReportPrint
er.java:49)
at main.java.gls_desktop.jasperreports.JasperReportsTestFile.<init>(Jasp
erReportsTestFile.java:61)
at main.java.gls_desktop.jasperreports.AlternateMainJasperReportsTest.ma
in(AlternateMainJasperReportsTest.java:15)
at main.java.gls_desktop.GLSapp.main(GLSapp.java:132)
bls61793's picture
Joined: Jan 30 2017 - 11:57am
Last seen: 2 years 8 months ago

1 Answer:

0

You need to use the lowercase property name for the field:

<field name="jobPK" class="main.java.gls.entities.JobPK">

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

</field>

narcism's picture
1149
Joined: Nov 22 2010 - 12:39am
Last seen: 12 hours 16 min ago
Feedback
randomness