Add XmlService classloader fallback for ServiceLoader discovery#12237
Open
gnodet wants to merge 1 commit into
Open
Add XmlService classloader fallback for ServiceLoader discovery#12237gnodet wants to merge 1 commit into
gnodet wants to merge 1 commit into
Conversation
When the thread context classloader cannot see the XmlService
provider (e.g. in plugin classloaders), fall back to loading
via XmlService's own classloader. This prevents
IllegalStateException("No XmlService implementation found")
in environments where the TCCL is isolated.
Co-authored-by: Arturo Bernal <abernal@apache.org>
gnodet
added a commit
to arturobernalg/maven
that referenced
this pull request
Jun 4, 2026
- Remove XmlService classloader fallback (extracted to PR apache#12237) - Use MavenModelVersion to compute the minimum model version instead of hardcoding 4.0.0 as the fallback - Align namespace/schemaLocation format strings with TransformerSupport conventions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Extracted from #11742 (by @arturobernalg) to keep the classloader fix separate from the namespace-preservation fix (#11715).
When the thread context classloader cannot see the
XmlServiceprovider (e.g. in isolated plugin classloaders), theServiceLoader.load(XmlService.class)call fails withIllegalStateException("No XmlService implementation found").This change:
XmlService.class.getClassLoader()first — this is the core realm classloader which always sees the providerXmlServicelives in the API module, and its classloader reliably sees theimpl/maven-xmlprovider through Maven's core realm. The TCCL may be a plugin classrealm or an isolated classloader that cannot.Test plan
XmlServiceLoadingTestverifies discovery works when TCCL is an emptyURLClassLoaderthat cannot see the providerClaude Code on behalf of Guillaume Nodet
Co-authored-by: Arturo Bernal abernal@apache.org