Repository navigation
Fix javax.servlet.error.exception in generated error.gsp templates - #16379
Conversation
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
🚨 TestLens detected 6 failed tests 🚨Here is what you can do:
Test SummaryEnd to End / End to End Tests (end-to-end build only) > :taglib-index-incremental:test [end-to-end]
🏷️ Commit: e1ec262 Test FailuresTagLibraryIndexIncrementalSpec > a deleted tag library is gone from the published index after a build with no clean (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only))
TagLibraryIndexIncrementalSpec > a deleted tag library is gone from the published index after a build with no clean (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only) | Attempt 1/2)
TagLibraryIndexIncrementalSpec > a renamed tag library does not leave its old name behind (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only))
TagLibraryIndexIncrementalSpec > a renamed tag library does not leave its old name behind (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only) | Attempt 1/2)
TagLibraryIndexIncrementalSpec > a tag removed from a tag library is gone from the index it is described by (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only))
TagLibraryIndexIncrementalSpec > a tag removed from a tag library is gone from the index it is described by (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only) | Attempt 1/2)
TagLibraryIndexIncrementalSpec > an executable archive carries the descriptors and not the settings (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only))
TagLibraryIndexIncrementalSpec > an executable archive carries the descriptors and not the settings (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only) | Attempt 1/2)
TagLibraryIndexIncrementalSpec > nothing writes a second index into the class output (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only))
TagLibraryIndexIncrementalSpec > nothing writes a second index into the class output (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only) | Attempt 1/2)
TagLibraryIndexIncrementalSpec > the settings this build declared reach no archive (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only))
TagLibraryIndexIncrementalSpec > the settings this build declared reach no archive (:taglib-index-incremental:test [end-to-end] in End to End / End to End Tests (end-to-end build only) | Attempt 1/2)
Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #16379 +/- ##
==================================================
- Coverage 56.3688% 56.3669% -0.0019%
+ Complexity 21884 21883 -1
==================================================
Files 2127 2127
Lines 103520 103520
Branches 18549 18549
==================================================
- Hits 58353 58351 -2
- Misses 36881 36882 +1
- Partials 8286 8287 +1 🚀 New features to boost your workflow:
|
matrei
left a comment
There was a problem hiding this comment.
Reviewed at head e1ec2629bd (1 commit) against 8.0.x. Merge-base is d4aa4effe0, the current tip of 8.0.x, so the branch is up to date and applies cleanly.
What I ran locally on the PR head:
cd grails-forge && ./gradlew :grails-forge-core:cleanTest :grails-forge-core:test --tests "org.grails.forge.feature.view.GrailsGspSpec" --no-build-cache— 21 tests, 0 failures, 0 errors (fresh result XML, not a cache hit).- Confirmed the two changed templates are byte-identical (
git rev-parsegives the same blob for both), so the newgsp/error.gspentry in the mirror test holds. javap -constantsonspring-web-7.0.9.jar:org.springframework.web.util.WebUtils.ERROR_EXCEPTION_ATTRIBUTE = "jakarta.servlet.error.exception".org.grails.web.util.WebUtilsextends that class, so the key the framework itself uses inGrailsExceptionResolver.setStatus()andUrlMappingsHandlerMappingis the one the templates now read.
Approving. Two things to decide before merging, neither is a defect in the change itself.
1. This belongs on 7.0.x first (or needs a backport)
The bug is not Grails 8 specific. 7.0.x and 7.2.x both ship grails-forge/ and grails-profiles/, and both error.gsp files there are the exact same blob as the pre-fix 8.0.x files (4fd96204784). Grails 7 is already on Jakarta EE 10 / Spring 6, where ERROR_EXCEPTION_ATTRIBUTE is the jakarta.* key, so every app generated by create-app or Forge on 7.x has the same dead <g:elseif> branch.
Normal flow here is lowest affected release branch and merge forward. The backport is trivial: the two one-word GSP edits plus the new GrailsGspSpec feature. Note the mirror test ("the profile skeleton mirrors the forge welcome templates") does not exist on 7.0.x / 7.2.x, so only the first hunk of the spec change carries over there.
2. The red End to End check is not caused by this PR
End to End Tests (end-to-end build only) fails in TagLibraryIndexIncrementalSpec — all 6 features, each on the assert status == 0 at line 158 (the nested Gradle build of the sample app fails). Nothing in this PR is on that path (it changes two GSP templates and a Forge spec).
Every End to End run since d4aa4effe0 ("bump publish plugin to 1.0.0-RC1") landed on 8.0.x at 18:33 UTC yesterday has failed the same way: run 35769412153 (fix/qualified-session-connection-scope, 44d95a6427) fails in exactly the same six features, and run 35793273082 (fix/gsp-page-scope-variable-scan-8.0.x) is also red, while every run before that commit is green. The push run for d4aa4effe0 itself was cancelled, so the regression never showed on the branch. That commit changes only the publish plugin version in dependencies.gradle, which is what the nested build resolves. Worth a separate issue against 8.0.x; it should not block this fix.
Minor / optional
- The issue lists six
grails-test-examples/**/error.gspfiles with the same stale key (mail,geb,geb-gebconfig,scaffolding,hibernate5/issue450,hibernate7/issue450). They are not user-facing and the PR title scopes itself to generated templates, so leaving them is fine; a follow-up sweep would keepgrep -r javax.servletclean. (app1/.../FlowTargetController.groovyalso readsjavax.servlet.forward.request_uri, same category.) - No
grails-docchange is needed: the docs never mentionservlet.error.exception.
Verified as correct
grails-forge/grails-forge-core/src/main/resources/gsp/error.gsp:14-15andgrails-profiles/web/skeleton/grails-app/views/error.gsp:14-15: bothgetAttributecalls switched; the<g:if test="${Throwable.isInstance(exception)}">branch above is untouched, and it remains the branch that fires in the common case becauseGrailsExceptionResolver.setStatus()puts the wrapped exception in the model under bothexceptionandjakarta.servlet.error.exception. The<g:elseif>is the container error-page path (exception escaping the resolver,sendError), which is exactly where the request attribute is set under the Jakarta key.GrailsGspSpec.groovy:84-92: generates a WEB app and asserts the jakarta lookup is present and the javax one absent. Tests through the same public generator path a user hits.GrailsGspSpec.groovy:330: addinggsp/error.gspto the byte-identity map is the right guard against future drift between Forge and thewebprofile; verified it passes against the PR head.- No other
error.gspexists in Forge resources or in the other profiles (rest-api,plugin,web-plugin), so the two files are the complete set of user-facing templates.
|
@matrei I assume, that the flaky tests (not related to this PR) can be ignored? |
@sbglasius Yes, this was a temporary glitch: |
|
FYI: these weren't flakes. Our end to end doesn't appear to have our repo settings. |
Summary
webapplication profileerror.gsptemplates still looked up the pre-Jakarta EE attributejavax.servlet.error.exception, so on Grails 8 (Jakarta EE 10) the lookup never matched and the branch that renders exception details in development mode never fired.jakarta.servlet.error.exception(jakarta.servlet.RequestDispatcher.ERROR_EXCEPTION), matching the container-set attribute name.error.gspto the existing forge/profile-skeleton byte-identity check so the two templates can't silently drift again.Reported on the mailing list; tracked in #16378.
Test plan
./gradlew :grails-forge-core:test --tests "org.grails.forge.feature.view.GrailsGspSpec"— all 21 tests pass