Skip to content

GlassFish: Don't pass removed -Djava.endorsed.dirs when running app clients - #9446

Merged
mbien merged 1 commit into
apache:masterfrom
renatsaf:issue-6270-appclient-endorsed-dirs
Jul 14, 2026
Merged

GlassFish: Don't pass removed -Djava.endorsed.dirs when running app clients#9446
mbien merged 1 commit into
apache:masterfrom
renatsaf:issue-6270-appclient-endorsed-dirs

Conversation

@renatsaf

Copy link
Copy Markdown
Contributor

What

When running a Jakarta EE application client against a registered GlassFish server, the run fails immediately because the spawned JVM cannot be created:

-Djava.endorsed.dirs=/Applications/glassfish7/glassfish/lib/endorsed:/Applications/glassfish7/glassfish/modules/endorsed is not supported. ...
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

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/endorsed to the app-client container JVM options. This value ends up in the generated build-impl.xml via j2ee.appclient.tool.jvmoptions and is passed as a <jvmarg> to the run-appclient macro.

The endorsed-standards mechanism was removed in JDK 9 (JEP 220), and HotSpot deliberately aborts at startup when java.endorsed.dirs is set. GlassFish 7 requires JDK 11+ and ships no endorsed directories at all, so the option is both invalid and pointing at non-existent paths.

Fix

Build -Djava.endorsed.dirs only from the lib/endorsed / modules/endorsed directories 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

  • The Payara plugin (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

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
@mbien mbien added Java EE/Jakarta EE [ci] enable enterprise job enterprise [ci] enable enterprise job labels Jun 16, 2026
@mbien mbien added this to the NB31 milestone Jul 13, 2026
@mbien
mbien requested a review from pepness July 13, 2026 13:32
@mbien mbien added the ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) label Jul 13, 2026
@apache apache locked and limited conversation to collaborators Jul 13, 2026
@apache apache unlocked this conversation Jul 13, 2026

@mbien mbien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good

@mbien mbien changed the title Don't pass removed -Djava.endorsed.dirs when running app clients GlassFish: Don't pass removed -Djava.endorsed.dirs when running app clients Jul 14, 2026
@mbien
mbien merged commit 5f08337 into apache:master Jul 14, 2026
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) enterprise [ci] enable enterprise job Java EE/Jakarta EE [ci] enable enterprise job

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't run Java enterprise application client against glassfish 7.0.6 server because VM won't create because of -Djava.endorsed.dirs

2 participants