You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running Spring Boot 3.2.1, and the spring-boot-starter-thymeleaf. This pulls Thymeleaf version 3.1.2.RELEASE.
When running the application I get the following error at first access of the thymeleaf template for the home path ("/" or ""):
1/20/2024, 12:43:26 PM [APP/PROC/WEB/0] OUT java.lang.IllegalArgumentException: Cannot build an application for a request which servlet context does not match with the application that it is being built for.
1/20/2024, 12:43:26 PM [APP/PROC/WEB/0] OUT at org.thymeleaf.util.Validate.isTrue(Validate.java:79)
1/20/2024, 12:43:26 PM [APP/PROC/WEB/0] OUT at org.thymeleaf.web.servlet.JakartaServletWebApplication.buildExchange(JakartaServletWebApplication.java:64)
1/20/2024, 12:43:26 PM [APP/PROC/WEB/0] OUT at org.thymeleaf.spring6.view.ThymeleafView.renderFragment(ThymeleafView.java:204)
1/20/2024, 12:43:26 PM [APP/PROC/WEB/0] OUT at org.thymeleaf.spring6.view.ThymeleafView.render(ThymeleafView.java:192)
...
I found #926 and #937 and they assume it being fixed with 3.1.x. Are we looking at a regression issue here? Thanks.
The text was updated successfully, but these errors were encountered:
The root context problem can be fixed with the following change in JakartaServletWebApplication:
private boolean servletContextMatches(final HttpServletRequest httpServletRequest) {
// We should not be directly matching servletContext objects because a wrapper might have been applied
final String servletContextPath = this.servletContext.getContextPath();
final String requestServletContextPath = httpServletRequest.getServletContext().getContextPath();
if (StringUtils.isEmpty(servletContextPath)
&& requestServletContextPath != null
&& requestServletContextPath.equals("/")) {
return true;
}
if (StringUtils.isEmpty(requestServletContextPath)
&& servletContextPath != null
&& servletContextPath.equals("/")) {
return true;
}
return Objects.equals(servletContextPath, requestServletContextPath);
}
It's the classical "context root identity" issue, i.e. is the context root empty or a slash, such as https://example.com/ vs. https://example.com. I don't know why this validation is necessary in the first place, but just ignoring the differentiation between "" and "/" as the context root makes sense to me. I don't think I can configure that accordingly.
I'm deploying the application into Open Liberty version 23.0.0.8.
Hi, following the issue as we see the same situation with openliberty 22.0.0.8, deployed in root context path this.servletContext.getContextPath();: "/" and httpServletRequest.getServletContext().getContextPath();: ""
Hello Thymeleaf Team,
I'm running Spring Boot 3.2.1, and the spring-boot-starter-thymeleaf. This pulls Thymeleaf version 3.1.2.RELEASE.
When running the application I get the following error at first access of the thymeleaf template for the home path ("/" or ""):
I found #926 and #937 and they assume it being fixed with 3.1.x. Are we looking at a regression issue here? Thanks.
The text was updated successfully, but these errors were encountered: