Scan web-fragment nested JARs for annotations in embedded ScatteredArchive#26100
Open
renatsaf wants to merge 1 commit into
Open
Scan web-fragment nested JARs for annotations in embedded ScatteredArchive#26100renatsaf wants to merge 1 commit into
renatsaf wants to merge 1 commit into
Conversation
…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>
b35b529 to
2159422
Compare
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.
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 inWEB-INF/lib) were silently ignored. OnlyWEB-INF/classes/*.classwas scanned.Root cause (two cooperating gaps):
EmbeddedWebScanner.process()inScatteredWebArchivistonly kept entries underWEB-INF/classes/.WebFragmentDescriptor.getArchiveFileEntries()returnedCollections.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 itsjarName(WEB-INF/lib/<jarName>) viagetSubArchive(...), 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 aWebFragmentDescriptor; it also skipsmodule-info.class.Test
Adds
ScatteredArchiveTest#testWebFragmentInNestedJar, which builds a web-fragment JAR at runtime (an@WebServletplusMETA-INF/web-fragment.xml), bundles it viaaddClassPath(→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-alluber jar:ScatteredArchiveTest(3 tests) green.Fixes #24592
🤖 Generated with Claude Code