You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by sb...@apache.org on 2026/09/23 05:36:22 UTC
(grails-core) 01/01: fix: use jakarta.servlet.error.exception in generated error.gsp
This is an automated email from the ASF dual-hosted git repository.
sbglasius pushed a commit to branch fix/error-gsp-jakarta-servlet-attribute
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit e1ec2629bd1bad273820e37962bc2404b4db6ced
Author: Søren Berg Glasius <so...@glasius.dk>
AuthorDate: Wed Sep 23 07:36:06 2026 +0200
fix: use jakarta.servlet.error.exception in generated error.gsp
The Grails Forge and web profile error.gsp templates still looked up
the pre-Jakarta EE attribute javax.servlet.error.exception. Since
Grails 8 targets Jakarta EE 10, the container stores the forwarded
exception under jakarta.servlet.error.exception
(jakarta.servlet.RequestDispatcher.ERROR_EXCEPTION), so the lookup
never matched and the elseif branch that renders exception details
never fired.
Fixes #16378
---
.../grails-forge-core/src/main/resources/gsp/error.gsp | 4 ++--
.../groovy/org/grails/forge/feature/view/GrailsGspSpec.groovy | 11 +++++++++++
grails-profiles/web/skeleton/grails-app/views/error.gsp | 4 ++--
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/grails-forge/grails-forge-core/src/main/resources/gsp/error.gsp b/grails-forge/grails-forge-core/src/main/resources/gsp/error.gsp
index 4fd9620478..4789b26420 100644
--- a/grails-forge/grails-forge-core/src/main/resources/gsp/error.gsp
+++ b/grails-forge/grails-forge-core/src/main/resources/gsp/error.gsp
@@ -11,8 +11,8 @@
<g:if test="${Throwable.isInstance(exception)}">
<g:renderException exception="${exception}" detailsClass="alert alert-danger" stackClass="bg-body-secondary" snippetClass="bg-body-secondary snippet" lineErrorClass="bg-danger" />
</g:if>
- <g:elseif test="${request.getAttribute('javax.servlet.error.exception')}">
- <g:renderException exception="${request.getAttribute('javax.servlet.error.exception')}" />
+ <g:elseif test="${request.getAttribute('jakarta.servlet.error.exception')}">
+ <g:renderException exception="${request.getAttribute('jakarta.servlet.error.exception')}" />
</g:elseif>
<g:else>
<ul class="errors">
diff --git a/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/view/GrailsGspSpec.groovy b/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/view/GrailsGspSpec.groovy
index cb65aa4232..443aa3f655 100644
--- a/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/view/GrailsGspSpec.groovy
+++ b/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/view/GrailsGspSpec.groovy
@@ -81,6 +81,16 @@ class GrailsGspSpec extends ApplicationContextSpec implements CommandOutputFixtu
output.containsKey("grails-app/views/notFound.gsp")
}
+ void "test default error page looks up the jakarta servlet error exception attribute"() {
+ when:
+ final def output = generate(ApplicationType.WEB, new Options(DevelopmentReloading.DEVTOOLS))
+ final String error = output["grails-app/views/error.gsp"]
+
+ then: "the container stores the forwarded exception under the jakarta attribute name, not the pre-Jakarta EE one"
+ error.contains("request.getAttribute('jakarta.servlet.error.exception')")
+ !error.contains("javax.servlet.error.exception")
+ }
+
void "test default index page is internationalized"() {
when:
final def output = generate(ApplicationType.WEB, new Options(DevelopmentReloading.DEVTOOLS))
@@ -317,6 +327,7 @@ class GrailsGspSpec extends ApplicationContextSpec implements CommandOutputFixtu
final Map<String, String> mirrored = [
"gsp/index.gsp" : "web/skeleton/grails-app/views/index.gsp",
"gsp/main.gsp" : "web/skeleton/grails-app/views/layouts/main.gsp",
+ "gsp/error.gsp" : "web/skeleton/grails-app/views/error.gsp",
"assets/stylesheets/welcome.css" : "web/skeleton/grails-app/assets/stylesheets/welcome.css",
"assets/javascripts/welcome.js" : "web/skeleton/grails-app/assets/javascripts/welcome.js",
]
diff --git a/grails-profiles/web/skeleton/grails-app/views/error.gsp b/grails-profiles/web/skeleton/grails-app/views/error.gsp
index 4fd9620478..4789b26420 100644
--- a/grails-profiles/web/skeleton/grails-app/views/error.gsp
+++ b/grails-profiles/web/skeleton/grails-app/views/error.gsp
@@ -11,8 +11,8 @@
<g:if test="${Throwable.isInstance(exception)}">
<g:renderException exception="${exception}" detailsClass="alert alert-danger" stackClass="bg-body-secondary" snippetClass="bg-body-secondary snippet" lineErrorClass="bg-danger" />
</g:if>
- <g:elseif test="${request.getAttribute('javax.servlet.error.exception')}">
- <g:renderException exception="${request.getAttribute('javax.servlet.error.exception')}" />
+ <g:elseif test="${request.getAttribute('jakarta.servlet.error.exception')}">
+ <g:renderException exception="${request.getAttribute('jakarta.servlet.error.exception')}" />
</g:elseif>
<g:else>
<ul class="errors">