1

Why am I getting PropertyNotFoundException?

Flight.java:

package com.bulbul.flightreservation.entities;

import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="Flight")
public class Flight extends AbstractEntity
{

    private String Flight_Number;
    public String Operating_Airlines;
    private String Departure_City;
    private String Arrival_City;
    private Date date_Of_Departure;
    private Timestamp estimated_departure_time;


    public String getFlight_Number() {
        return Flight_Number;
    }
    public void setFlight_Number(String flight_Number) {
        Flight_Number = flight_Number;
    }

    public String getOperating_Airlines() {
        return Operating_Airlines;
    }
    public void setOperating_Airlines(String Operating_Airlines) {
        this.Operating_Airlines =Operating_Airlines;
    }
    public String getDeparture_City() {
        return Departure_City;
    }
    public void setDeparture_City(String departure_City) {
        Departure_City = departure_City;
    }
    public String getArrival_City() {
        return Arrival_City;
    }
    public void setArrival_City(String arrival_City) {
        Arrival_City = arrival_City;
    }   
    public Timestamp getEstimated_departure_time() {
        return estimated_departure_time;
    }
    public void setEstimated_departure_time(Timestamp estimated_departure_time) {
        this.estimated_departure_time = estimated_departure_time;
    }
    public Date getDate_Of_Departure() {
        return date_Of_Departure;
    }
    public void setDate_Of_Departure(Date date_Of_Departure) {
        this.date_Of_Departure = date_Of_Departure;
    }



}

Controller.java:

@RequestMapping(value="/findFlights",method=RequestMethod.POST)
    public String findFlights(@RequestParam("from") String from,@RequestParam("to") String to,
            @RequestParam("date_Of_Departure") @DateTimeFormat(pattern="yyyy-MM-dd") Date date_Of_Departure,ModelMap modelMap)
    {
        List<Flight> flight = flightRepository.findFlights(from,to,date_Of_Departure);
        modelMap.addAttribute("flight",flight);
        return "displayFlights";
    }
    @RequestMapping(value="/Already_User",method=RequestMethod.GET)
    public String alreadyUser()
    {
        return "login/login";
    }

FlightRepository.java

package com.bulbul.flightreservation.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.bulbul.flightreservation.entities.Flight;

public interface FlightRepository extends JpaRepository<Flight,Long>
{

    @Query("from Flight where Departure_City=:Departure_City and Arrival_City=:Arrival_City and date_Of_Departure=:date_Of_Departure")
    List<Flight> findFlights(@Param("Departure_City") String from,@Param("Arrival_City")
    String to,@Param("date_Of_Departure") Date date_Of_Departure);

}

displayFlight.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Display Flights</title>
</head>
<body>
    <center>
        <h1>Flight Available</h1>
        <table>
            <tr>
                <th>Operating_Airlines</th>
                <th>Departure_City</th>
                <th>Arrival_City</th>
                <th>Departure_Time</th>
            </tr>
<c:forEach items="${flight}" var="flight">
<tr>
<td>${flight.Operating_Airlines}</td>
<td>${flight.Departure_City}</td>
<td>${flight.Arrival_City}</td>
<td>${flight.Departure_Time}</td>
<td><a href=showCompleteReservation?id=${flight.id}>Select</a></td>
</tr>
</c:forEach>
        </table>
    </center>
</body>
</html>

Exception:Property [Operating_Airlines] not found on type [com.bulbul.flightreservation.entities.Flight]

javax.el.PropertyNotFoundException: Property [Operating_Airlines] not found on type [com.bulbul.flightreservation.entities.Flight]
    at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:260) ~[tomcat-embed-el-8.5.34.jar:8.5.34]
    at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:212) ~[tomcat-embed-el-8.5.34.jar:8.5.34]
    at javax.el.BeanELResolver.property(BeanELResolver.java:347) ~[tomcat-embed-el-8.5.34.jar:8.5.34]
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:92) ~[tomcat-embed-el-8.5.34.jar:8.5.34]
    at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110) ~[tomcat-embed-jasper-8.5.34.jar:8.5.34]
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169) ~[tomcat-embed-el-8.5.34.jar:8.5.34]
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190) ~[tomcat-embed-el-8.5.34.jar:8.5.34]
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:944) ~[tomcat-embed-jasper-8.5.34.jar:8.5.34]
    at org.apache.jsp.WEB_002dINF.jsps.displayFlights_jsp._jspx_meth_c_005fforEach_005f0(displayFlights_jsp.java:196) ~[na:na]
    at org.apache.jsp.WEB_002dINF.jsps.displayFlights_jsp._jspService(displayFlights_jsp.java:138) ~[na:na]
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ~[tomcat-embed-jasper-8.5.34.jar:8.5.34]
Alex
  • 7,743
  • 1
  • 18
  • 38
Rekha
  • 37
  • 2
  • remove underscore. possible duplicate of https://stackoverflow.com/questions/23456197/spring-data-jpa-repository-underscore-on-entity-column-name – boly38 Oct 21 '18 at 18:18
  • @Rebi Firstly, your naming convention is wrong. fields are private and are camelCased in Java not snake_case with Capitals. Make those changes and re-create the database. – Chirdeep Tomar Oct 21 '18 at 18:30

0 Answers0