javajspservletspropertynotfoundexception

Property '{nameOfProperty}' not found on type Bean


I keep getting this exception: javax.el.PropertyNotFoundException: Property 'totalMaleTrainers' not found on type com.beans.Report when I try to display the value of totalMaleTrainers, it works fine when I display the other values. Note that I just recently added this property in my 'Report' Bean.

I already tried to search and find if others had the a same problem with mine but I didn't get the solution. I tried rewriting the 'Report' Bean but I still get an Exception.

REPORT BEAN

public class Report {
  private Integer totalMaleTrainers;

  public Integer getTotalMaleTr() {
    return totalMaleTrainers;
  }
  public void setTotalMaleTr(Integer totalMaleTrainers) {
    this.totalMaleTrainers = totalMaleTrainers;
  }
}

CONTROLLER

Report schoolReport = null;
try{
  schoolReport = reportmanager.getSchoolReport(sch_id);
  request.setAttribute("report", schoolReport);
}

JSP

<p>${report.totalMaleTrainers}</p>

EXCEPTION

javax.el.PropertyNotFoundException: Property 'totalMaleTrainers' not found on type com.beans.Report

I also tried to convert it to a JSONObject using GSON() to test if totalMaleTrainers is in it and it is.

{"totalRoadTrainers":190,"totalMaleTrainers":214}

Solution

  • You can call getter method:

    <p>${report.getTotalMaleTr()}</p>
    

    Or make your property public:

    public Integer totalMaleTrainers;
    

    Or try recreate getter method using your IDE