Skip to content

spring boot 4, iterable of objects empty in template #334

@pnoe

Description

@pnoe

Hi,
I am trying to upgrade a spring boot mvc tymeleaf application from spring boot 3.5.8 to spring boot 4.0.0.

  • jdk 25, tomcat 11, ubuntu 25.10

In a controller :

Iterable<RucherMap> ruchers;
 ruchers = rucherRepository.findRucherMapByActifTrue();
 List<String> nomRuches = new ArrayList<>();
 for (RucherMap rucher : ruchers) {
   nomRuches.add(rucheRepository.findByRucherId(rucher.id()).stream().map(Nom::nom)
   .reduce("", (a, b) -> a + " " + b).trim());
 }
 model.addAttribute(Const.RUCHENOMS, nomRuches);
 model.addAttribute(Const.RUCHERS, ruchers);
 return "templateThymeleaf";

In java debug mode everything is ok (identical spring boot 3 or 4)
ruchers list of objects of type RucherMap
nomRuches list of strings

But in the Thymeleaf template

<script th:inline="javascript">
  const ruchers = /*[[${ruchers}]]*/ null;
  const nomRuches = /*[[${rucheNoms}]]*/ null;
  ...

Source code of the html template page :
Spring boot 3 :

	const ruchers = [{"id":2623,"depot":false,"nom":"Riez-272","longitude":6.0708833,"latitude":43.80421,"altitude":569,"dessin":null},{"id":414,"depot":false,"nom":"Relais St Ser","longitude":5.64433,"latitude":43.529827,"altitude":429,"dessin":null}, ...
	const nomRuches = ["","FG JC LK DR FU SC LI SJ BE GV SB","","JG JW KG EF GM ES KD GX DS GE GR", ...

Spring boot 4 :
```
const ruchers = [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}];
const nomRuches = ["","FG JC LK DR FU SC LI SJ BE GV SB","","JG JW KG EF GM ES KD GX DS GE GR", ...


The iterable "ruchers" contains empty objects.
"nomRuches" list of strings is ok.

I have no error in java log, and no error in javascript console.


Thanks for your help.

Pierre.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions