I would like to premise that I have read all the answers to questions similar to mine, but they did not help me. Usually this error appears when the get and set methods for a property are missing, but I put them. To those who told me to clean up the project and redistribute it, I cannot redistribute it because the server is integrated in the org.springframework.boot.web.embedded.tomcat package which in turn descends from the spring-boot-2.5.4 package root, i removed all other servers. Then I made a copy of the project and converted it to a web dynamic project to be able to add it to the server I had installed, but it gave me other errors. However in the end I had to convert it back to a maven project again for other errors, but I was left with the option to add it to the non-embedded server.
Now I don't know if it is better to remove the embedded server dependencies and add the server in eclipse from the beginning on the old project, which in any case you have to see why it doesn't work, or it is better to continue debugging the errors of the web project that I can add to the server.
When the server is integrated, how do you clean it up and redeploy the application?
To be more precise, the main page appears to me, if I click on "parliamentari" the page appears but the for of the list of parliamentarians does not work, while if I then delete the word .jsp in the url, the page appears with the list of parliamentarians. If I go back to the main page and click on loaded periods, the title and the empty page appear, so the for does not work, if I delete the .jsp extension in the url, I get the error for which I opened my question.
If I open the terminal and enter mvn clean install, it tells me that the environment variable is not configured correctly, but if I don't remove the jre folder from the java folder, eclipse just won't start.
mvn clean install
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
lista_periodi_cariche.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.giuggiola.entity.Parlamentare" %>
<%@ page import="com.giuggiola.entity.Periodi_cariche" %>
<%@ page
import=
"com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType" %>
<%@ page import="com.vladmihalcea.hibernate.type.range.Range" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Lista periodi cariche dei parlamentari</title>
<%@ page %>
<script src="<c:url value="/resources/js/jquery-1.11.1.min.js"
/>"></script>
<script src="<c:url value="/resources/js/bootstrap.min.js" />">
</script>
</head>
<body>
<h2>Lista periodi cariche:</h2>
<form action="getPeriodi_cariche">
<h1>Periodi delle cariche: </h1>
<c:forEach items="${periodi_cariche}" var="per_car">
<tr>
<td>Nome:</td>
<td>${per_car.nome}</td>
<td>Mandato/commissione:</td>
<td>${per_car.mandato_commissione}</td>
<td>Periodo carica:</td>
<td>${per_car.periodo_carica}</td>
</c:forEach>
</form>
</body>
</html>
Periodi_cariche.java
@EmbeddedId
private Range2PK pk;
private Range<LocalDate> periodo_carica;
Range2PK.java
@Embeddable
public class Range2PK implements Serializable{
private static final long serialVersionUID = 1;
@Column(name="nome", nullable=false)
protected String nome;
@Column(name = "mandato_commissione", nullable=false)
protected String mandato_commissione;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
stacktrace:
Stacktrace:
2022-09-12 14:27:52.180 ERROR 6176 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].
[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context
with path [] threw exception [An exception occurred processing
[/lista_periodi_cariche.jsp] at line [32]
29:
30: <tr>
31: <td>Nome:</td>
32: <td>${per_car.nome}</td>
33: <td>Mandato/commissione:</td>
34: <td>${per_car.mandato_commissione}</td>
35: <td>Periodo carica:</td>
Stacktrace:] with root cause
javax.el.PropertyNotFoundException: Property [nome] not found on type
[com.giuggiola.entity.Periodi_cariche]
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:251) ~[tomcat-el-
api-9.0.52.jar:3.0.FR]
at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:203) ~
[tomcat-el-api-9.0.52.jar:3.0.FR]
at javax.el.BeanELResolver.property(BeanELResolver.java:324) ~[tomcat-el-api-
9.0.52.jar:3.0.FR]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:83) ~[tomcat-el-api-
9.0.52.jar:3.0.FR]
at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:124) ~
[tomcat-jasper-9.0.52.jar:9.0.52]
at org.apache.el.parser.AstValue.getValue(AstValue.java:168) ~[tomcat-jasper-el-
9.0.52.jar:9.0.52]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) ~[tomcat-
jasper-el-9.0.52.jar:9.0.52]
at
...
2022-09-12 14:27:52.183 DEBUG 6176 --- [nio-8080-exec-3]
o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error",
parameters={}
2022-09-12 14:27:52.186 DEBUG 6176 --- [nio-8080-exec-3]
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to
org.springframework.boot.autoconfigure.web.servlet.error.
BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2022-09-12 14:27:52.211 DEBUG 6176 --- [nio-8080-exec-3]
o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html,
text/html;q=0.8]
2022-09-12 14:27:52.219 DEBUG 6176 --- [nio-8080-exec-3]
o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 500
RangeRepository.java
public interface RangeRepository extends
JpaRepository<Periodi_cariche, Range2PK>{ //CrudRepository<Parlamentare,PK>
//CrudRepository<Periodi_cariche,Range2PK>{
@Query(value="select nome from Periodi_cariche where nome=?1 order by
nome",nativeQuery = true)
public List<Periodi_cariche> findByNome(String nome);
@Query(value="select * from Periodi_cariche "
// + "where mandato/commissione=?1 order by mandato/commissione"
,nativeQuery = true)
public List<Periodi_cariche> findByMandatoCommissione(String mandato_commissione);
@Query(value="select * from Periodi_cariche "
//+ "where periodo_carica=?1 order by periodo_carica"
,nativeQuery = true)
public List<Periodi_cariche> findByPeriodo(Range<LocalDate> periodo);
//@Query(value="select nome,mandato_commissione,periodo_carica from Periodi_cariche
where periodo_carica=?1 order by periodo_carica", nativeQuery = true)
//public List<Periodi_cariche> findAll();// {
// return
//}
ParlamentareController.java
@RequestMapping("/lista_periodi_cariche")
@ResponseBody
public ModelAndView getPeriodi_cariche()
{
ModelAndView mv = new ModelAndView();
//Iterable<Parlamentare> parlamentari = parlamRepo.findAll();
List<Periodi_cariche> periodi_cariche =(List) periodiRepo.findAll();
mv.addObject("periodi_cariche", periodi_cariche);
// mv.addObject("parlamentari",parlamentari);
mv.setViewName("lista_periodi_cariche.jsp");
return mv;
}
lista_periodi_cariche.jsp
<h1>Periodi delle cariche: </h1>
<c:forEach items="${periodi_cariche}" var="per_car">
<tr>
<td>Nome:</td>
<td>${per_car.nome}</td>
<td>Mandato/commissione:</td>
<td>${per_car.mandato_commissione}</td>
<td>Periodo carica:</td>
<td>${per_car.periodo_carica}</td>
</c:forEach>
</form>