Don't pass removed -Djava.endorsed.dirs when running app clients#9446
Open
renatsaf wants to merge 1 commit into
Open
Don't pass removed -Djava.endorsed.dirs when running app clients#9446renatsaf wants to merge 1 commit into
renatsaf wants to merge 1 commit into
Conversation
When running a Jakarta EE application client against a registered
GlassFish server, the GlassFish plugin built the app-client container
JVM options by always prepending
-Djava.endorsed.dirs=<root>/lib/endorsed:<root>/modules/endorsed.
The endorsed-standards mechanism was removed in JDK 9 (JEP 220), and
HotSpot deliberately aborts at startup when java.endorsed.dirs is set:
-Djava.endorsed.dirs=... is not supported. ...
Error: Could not create the Java Virtual Machine.
GlassFish 7 requires JDK 11+ and ships no endorsed directories, so the
app client run failed every time with no way to recover from the IDE.
Build the option only from the lib/endorsed and modules/endorsed
directories that actually exist, and omit -Djava.endorsed.dirs entirely
when neither is present. This fixes running app clients on JDK 9+ while
preserving behavior for legacy servers on JDK 8 that still ship those
directories.
Fixes apache#6270
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.
What
When running a Jakarta EE application client against a registered GlassFish server, the run fails immediately because the spawned JVM cannot be created:
The deploy succeeds; only the client JVM launch fails, every time.
Root cause
Hk2JavaEEPlatformImpl.getToolProperty(TOOL_APP_CLIENT_RUNTIME, TOOL_PROP_JVM_OPTS)always prepended-Djava.endorsed.dirs=<root>/lib/endorsed:<root>/modules/endorsedto the app-client container JVM options. This value ends up in the generatedbuild-impl.xmlviaj2ee.appclient.tool.jvmoptionsand is passed as a<jvmarg>to therun-appclientmacro.The endorsed-standards mechanism was removed in JDK 9 (JEP 220), and HotSpot deliberately aborts at startup when
java.endorsed.dirsis set. GlassFish 7 requires JDK 11+ and ships noendorseddirectories at all, so the option is both invalid and pointing at non-existent paths.Fix
Build
-Djava.endorsed.dirsonly from thelib/endorsed/modules/endorseddirectories that actually exist, and omit the option entirely when neither is present. This lets app clients run on JDK 9+ (modern GlassFish), while preserving behavior for legacy servers on JDK 8 that still ship those directories.Notes
payara.jakartaee) carries the same forked code; left out of this PR to keep it focused on the reported GlassFish case, but it should get the same treatment in a follow-up.Fixes #6270