Skip to content

8.0.0-SNAPSHOT grails-converters needs compileOnlyApi for jakarta.servlet-api - #16356

Merged
jdaugherty merged 2 commits into
apache:8.0.xfrom
codeconsole:fix/converters-servlet-compile-only-api-8.0.x
Sep 21, 2026
Merged

jdaugherty merged 2 commits into
apache:8.0.xfrom
codeconsole:fix/converters-servlet-compile-only-api-8.0.x

Conversation

@codeconsole

@codeconsole codeconsole commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

ConvertersExtension is a Groovy extension module whose getJSON/getXML signatures take HttpServletRequest. The Groovy compiler loads extension modules from any compile classpath they are on, so a module that depends on grails-converters without a web starter fails compileGroovy:

NoClassDefFoundError: Unable to configure org.grails.web.converters.ConvertersExtension due to missing dependency jakarta/servlet/http/HttpServletRequest

Declare the servlet API compileOnlyApi, as grails-controllers, grails-web-gsp and grails-web-taglib already do. Runtime classpath unchanged; the module metadata puts it on apiElements only.

Note: #16237 moves getXML into a new grails-xml with a compileOnly servlet declaration, which would need the same change.

ConvertersExtension is a Groovy extension module whose getJSON and getXML
signatures take HttpServletRequest. The Groovy compiler loads every
extension module it finds on a compile classpath before compiling anything,
so any module that depends on grails-converters without a web starter on
its classpath fails compileGroovy with

  General error during canonicalization: java.lang.NoClassDefFoundError:
  Unable to configure org.grails.web.converters.ConvertersExtension due to
  missing dependency jakarta/servlet/http/HttpServletRequest

The servlet API was declared compileOnly, so consumers only compiled when
something else happened to supply it. In a plugin build that something was
usually grails-console, added to the compile classpath by the CLI companion
probe; turning the probe off (grailsCliAutoProvision=false) exposed the
missing declaration.

compileOnlyApi puts the servlet API on consumers' compile classpaths while
leaving the runtime classpath to the container, which is what
grails-controllers, grails-web-gsp and grails-web-taglib already declare.
The duplicate compileOnly line further down is dropped.
@codeconsole
codeconsole requested review from borinquenkid, jdaugherty, matrei and sbglasius and removed request for matrei September 20, 2026 22:03
@codeconsole codeconsole changed the title Expose the servlet API on grails-converters' compile classpath 8.0.0-SNAPSHOT grails-converters needs compileOnlyApi for jakarta.servlet-api Sep 20, 2026
@codeconsole codeconsole added this to the grails:8.0.0-RC1 milestone Sep 20, 2026
@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.1169%. Comparing base (3dc3632) to head (6a4e044).

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                8.0.x     #16356        +/-   ##
==================================================
- Coverage     56.1295%   56.1169%   -0.0126%     
+ Complexity      21611      21610         -1     
==================================================
  Files            2123       2123                
  Lines          102887     102887                
  Branches        18396      18396                
==================================================
- Hits            57750      57737        -13     
- Misses          36893      36909        +16     
+ Partials         8244       8241         -3     

see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🚨 All tests passed but jobs failed 🚨

Failed Jobs without Test Failures

❌ CI / Build Grails-Core (macOS JDK 21)

🏷️ Commit: 6a4e044
▶️ Tests: 28639 executed
⚪️ Checks: 88/88 completed


Learn more about TestLens at testlens.app/docs.

@matrei matrei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this for grails-web-core and grails-mimetypes as well for completeness?

@jdaugherty

Copy link
Copy Markdown
Contributor

@matrei that's probably a good idea, i'd like to go ahead and merge this to get the RC1 milestone closer to getting done. Will you open a separate PR?

@jdaugherty
jdaugherty merged commit 0728b2f into apache:8.0.x Sep 21, 2026
153 of 155 checks passed
@matrei

matrei commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@matrei that's probably a good idea, i'd like to go ahead and merge this to get the RC1 milestone closer to getting done. Will you open a separate PR?

@jdaugherty Opened #16360

codeconsole pushed a commit to codeconsole/grails-core that referenced this pull request Sep 21, 2026
…mimetypes

Both modules ship a Groovy extension module with servlet types in its
signatures. The Groovy compiler loads extension modules from any compile
classpath they are on, so a consumer without the servlet API fails
compileGroovy with a NoClassDefFoundError. Follow-up to apache#16356, which
did the same for grails-converters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants