Include jakarta.servlet-api in CLI runtime classpath#15392
Merged
jamesfredley merged 1 commit intoapache:7.0.xfrom Feb 18, 2026
Merged
Include jakarta.servlet-api in CLI runtime classpath#15392jamesfredley merged 1 commit intoapache:7.0.xfrom
jamesfredley merged 1 commit intoapache:7.0.xfrom
Conversation
The grails-cli shadow JAR bundles grails-web-common (which registers HttpServletRequestExtension as a Groovy extension module) but excluded jakarta.servlet-api since it was declared compileOnly. This caused NoClassDefFoundError for jakarta/servlet/ServletRequest when the CLI compiled custom scripts in src/main/scripts/. Change compileOnly to implementation so the servlet API is included in the shadow JAR and available to the GroovyClassLoader at runtime.
Contributor
|
Why not just exclude the extension when the shadow jar is built? |
Contributor
Author
|
It appears to be required for create-controller, create-domain-class, generate-all, create-service, scaffolding, GSP/view generation, URL mappings, etc.) need to parse, understand, and generate code that uses Grails web-layer concepts |
jdaugherty
approved these changes
Feb 17, 2026
Contributor
jdaugherty
left a comment
There was a problem hiding this comment.
I think this is the right solution then, if @matrei agrees, we can merge.
Contributor
|
LGTM |
jamesfredley
added a commit
that referenced
this pull request
Feb 19, 2026
…n scope Document the rationale for the compileOnly-to-implementation change from PR #15392. The servlet API must be on the shadow JAR runtime classpath because grails-web-common's HttpServletRequestExtension is auto-discovered during script compilation, and CLI commands that generate web-layer code also depend on it. Assisted-by: Claude Code <Claude@Claude.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NoClassDefFoundErrorforjakarta/servlet/ServletRequestwhengrailswcompiles custom scripts insrc/main/scripts/Problem
The
grails-clishadow JAR bundlesgrails-web-common(which registersHttpServletRequestExtensionas a Groovy extension module), butjakarta.servlet-apiis declared ascompileOnlyingrails-shell-cli. This means the servlet API classes are excluded from the fat JAR.When the CLI's
GroovyScriptCommandFactorycompiles custom command scripts, the Groovy compiler auto-discovers theHttpServletRequestExtensionfrom the fat JAR's classpath. Initializing this extension requiresjakarta.servlet.ServletRequest, which is missing — causing allgrailswcommands to fail when custom scripts exist insrc/main/scripts/.Fix
Change
jakarta.servlet-apifromcompileOnlytoimplementationingrails-shell-cli/build.gradleso it is included in the shadow JAR's runtime classpath.Reproduction
src/main/scripts/./grailsw dbm-gorm-diff(or any grailsw command)Failed to compile <script>.groovy: Unable to configure org.grails.web.mime.HttpServletRequestExtension due to missing dependency jakarta/servlet/ServletRequest