Skip to content

Bundle jersey-cdi-rs-inject to allow @Inject of Jakarta REST artifacts#26079

Open
renatsaf wants to merge 4 commits into
eclipse-ee4j:mainfrom
renatsaf:fix-issue-25323-jersey-cdi-rs-inject
Open

Bundle jersey-cdi-rs-inject to allow @Inject of Jakarta REST artifacts#26079
renatsaf wants to merge 4 commits into
eclipse-ee4j:mainfrom
renatsaf:fix-issue-25323-jersey-cdi-rs-inject

Conversation

@renatsaf

Copy link
Copy Markdown
Contributor

Restores the Jersey module org.glassfish.jersey.ext.cdi:jersey-cdi-rs-inject in the web featureset, so Jakarta REST artifacts (UriInfo, Sse, SecurityContext, ...) can be injected with the standard CDI @Inject annotation — including constructor injection, which @Context cannot offer for CDI/EJB-managed resources.

As discussed with @OndroMih in #25323, the original reason for removing the module is gone:

Changes

  1. Re-enable jersey-cdi-rs-inject in appserver/featuresets/web/pom.xml (uncommented; the stale comment now explains the history). The module lands in modules/ of both the full and web-profile distributions.
  2. rest_cdi TCK now declares the module with provided scope, so the test WAR exercises the server-bundled module instead of shipping its own copy (verified: the deployed WAR has no WEB-INF/lib).
  3. Documentation: new "Injecting Jakarta REST Artifacts with CDI" section in the Application Development Guide documenting the module as a supported extension, plus a "What's New" bullet in the Release Notes.
  4. REST TCK runner fix: pin JUnit 5 in appserver/tests/tck/rest/pom.xml. The Jakarta REST TCK 4.0.0 artifact is built for JUnit 5; after the parent moved dependency management to JUnit 6, test discovery in this module failed with NoClassDefFoundError before any test ran. This pin was needed to be able to run the suite for this PR at all.

TCK verification (local, Windows, JDK 21)

Suite Result
CDI TCK 4.1.0 full 1334/1334 passed (incl. ProcessBeanAttributesNotFiredForBuiltinBean), model + signature passed
rest_cdi (internal) 1/1 passed, using the server-bundled module
Jakarta REST TCK 4.0.0 2796 run; the only 5 errors are identical with and without the module (4 Windows socket-aborts on status-408 tests + a sigtest static-mode classpath-separator issue on Windows; reflection mode passed all packages), so none are caused by this change

Fixes #25323

🤖 Generated with Claude Code

renatsaf and others added 3 commits June 11, 2026 00:05
The module was removed in the past because it made GlassFish fail the CDI TCK
test ProcessBeanAttributesNotFiredForBuiltinBean (jakartaee/cdi-tck#474).
That test was fixed by jakartaee/cdi-tck#475 to only assert on beans with the
@default qualifier, so the module can be restored.

The rest_cdi TCK war now uses the server-provided module instead of bundling
its own copy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Jakarta REST TCK 4.0.0 artifact is built for JUnit 5. Since the GlassFish
parent moved dependency management to JUnit 6, test discovery in this module
fails with NoClassDefFoundError (jupiter-api 5.10.2 mixed with engine 6.x).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@OndroMih

Copy link
Copy Markdown
Contributor

@dmatej , @arjantijms , can you verify that this PR passes the Jakarta EE TCK (at least CDI and REST), and also MP REST Client TCK?

<glassfish.home>${glassfish.root}/glassfish8</glassfish.home>
</properties>

<!-- The Jakarta REST TCK 4.0.0 is built for JUnit 5. Pin all JUnit artifacts to JUnit 5

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.

Is this really needed, @dmatej ? Do we use this runner nowadays?

@@ -1,3 +1,19 @@
//

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.

We don't add copyright headers to adoc files, please remove this header.

@@ -1,3 +1,19 @@
//

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.

We don't add copyright headers to adoc files, please remove this header.

* xref:embedded-server-guide.adoc#running-from-command-line[Runnable Embedded GlassFish JAR] (since {productName} 7.0.18)
* xref:administration-guide.adoc#log-executed-admin-commands[Admin Command Logger] (since {productName} 7.0.16)
* https://github.com/eclipse-ee4j/glassfish/discussions/25343[SSH nodes on Windows] via the native Windows SSH service (since {productName} 7.0.23)
* xref:application-development-guide.adoc#injecting-jakarta-rest-artifacts-with-cdi[CDI injection of Jakarta REST artifacts] using `@Inject` via the bundled Jersey `jersey-cdi-rs-inject` extension (since {productName} {product-majorVersion}.0.4)

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.

Version 8.0.4 should never change, while {product-majorVersion} will change when Glassfish 9 is released.

Suggested change
* xref:application-development-guide.adoc#injecting-jakarta-rest-artifacts-with-cdi[CDI injection of Jakarta REST artifacts] using `@Inject` via the bundled Jersey `jersey-cdi-rs-inject` extension (since {productName} {product-majorVersion}.0.4)
* xref:application-development-guide.adoc#injecting-jakarta-rest-artifacts-with-cdi[CDI injection of Jakarta REST artifacts] using `@Inject` via the bundled Jersey `jersey-cdi-rs-inject` extension (since {productName} 8.0.4)

…se notes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dmatej

dmatej commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@dmatej , @arjantijms , can you verify that this PR passes the Jakarta EE TCK (at least CDI and REST), and also MP REST Client TCK?

I believe it is not required, the issue was created for a milestone, while 8.0 0 already passed all tck tests without this.

Also we already use later junit if I remember well. EDIT: aha, I read the description why this, I will check tomorrow, now I read this on a cell phone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constructor Inject Sse failed

3 participants