Skip to content

Scan web-fragment nested JARs for annotations in embedded ScatteredArchive#26100

Open
renatsaf wants to merge 1 commit into
eclipse-ee4j:mainfrom
renatsaf:scatteredarchive-fragment-scan-24592
Open

Scan web-fragment nested JARs for annotations in embedded ScatteredArchive#26100
renatsaf wants to merge 1 commit into
eclipse-ee4j:mainfrom
renatsaf:scatteredarchive-fragment-scan-24592

Conversation

@renatsaf

Copy link
Copy Markdown
Contributor

Problem

When a web application is deployed to GlassFish Embedded as a ScatteredArchive, annotated components (servlets, filters, listeners, …) bundled inside a nested JAR (a web fragment in WEB-INF/lib) were silently ignored. Only WEB-INF/classes/*.class was scanned.

Root cause (two cooperating gaps):

  • EmbeddedWebScanner.process() in ScatteredWebArchivist only kept entries under WEB-INF/classes/.
  • WebFragmentDescriptor.getArchiveFileEntries() returned Collections.emptyEnumeration(), so when the scanner processed a fragment descriptor it got nothing.

This is the follow-up that was explicitly left out of scope in #24570.

Fix

  • WebFragmentDescriptor.getArchiveFileEntries() now opens the nested JAR referenced by its jarName (WEB-INF/lib/<jarName>) via getSubArchive(...), eagerly materializes the entry names (so the sub-archive can be closed), and returns them.
  • EmbeddedWebScanner.process() selects the class-name prefix by descriptor type: WEB-INF/classes/ for the web module, JAR-relative ("") for a WebFragmentDescriptor; it also skips module-info.class.

Test

Adds ScatteredArchiveTest#testWebFragmentInNestedJar, which builds a web-fragment JAR at runtime (an @WebServlet plus META-INF/web-fragment.xml), bundles it via addClassPath (→ WEB-INF/lib), deploys, and asserts the servlet responds. The servlet class is present only inside the nested JAR, so it is reachable only if the JAR is scanned.

Verified end-to-end against a rebuilt glassfish-embedded-all uber jar:

  • With the fix: new test passes; full ScatteredArchiveTest (3 tests) green.
  • Without the fix: the new test fails (servlet 404) — confirming it is a genuine regression guard.

Fixes #24592

🤖 Generated with Claude Code

…chive

When a web app is deployed to GlassFish Embedded as a ScatteredArchive,
annotated components bundled inside a nested JAR (a web fragment in
WEB-INF/lib) were silently ignored, because the embedded scanner only
looked at WEB-INF/classes and WebFragmentDescriptor returned no entries.

WebFragmentDescriptor.getArchiveFileEntries now opens the nested JAR
referenced by its jarName and returns its class entries, and
EmbeddedWebScanner processes those JAR-relative entries (skipping
module-info.class). Adds a reproducer test that bundles an annotated
servlet in a nested web-fragment JAR and asserts it is deployed.

Fixes eclipse-ee4j#24592

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

GlassFish Embedded" WebFragmentDescriptor in ScatteredArchive should return all classes in the nested JAR file referenced from the descriptor

1 participant