slachiewicz opened a new issue, #14185: URL: https://github.com/apache/maven/issues/14185
### Affected version 3.9.16, 3.10.1, 3.10.2. Not affected: 4.0.0-rc-7. ### Bug description A core extension registered in `.mvn/extensions.xml` that calls `PlexusContainer.lookup(role, hint)` from its own code, for example in `AbstractMavenLifecycleParticipant.afterProjectsRead`, gets `ComponentLookupException: java.util.NoSuchElementException` for every component, both core ones (`ProjectBuilder`, `BuildPluginManager`) and maven-compat ones (`ArtifactResolver`, `WagonManager`, …). The thread context class loader is the extension's realm at that point, which is what Maven sets when it invokes the participant. The same extension works when loaded with `-Dmaven.ext.class.path`, and it works on 4.0.0-rc-7. Looking up the same components with the TCCL switched to `container.getContainerRealm()` works on every version. | Maven | `.mvn/extensions.xml` | `-Dmaven.ext.class.path` | |---|---|---| | 3.9.16 | 0 of 37 lookups succeed | 37 of 37 | | 3.10.2 | 0 of 37 | 37 of 37 | | 4.0.0-rc-7 | 35 of 37 (the two that fail are not present in Maven 4) | 35 of 37 | When core extensions are present, Maven builds the container on a `maven.ext` realm whose parent is `plexus.core`. Components are scanned through `maven.ext`. A core extension realm has `plexus.core` as its parent and does not import `maven.ext`, so Plexus realm visibility (`RealmManager.visibleRealmNames`) filters every component out of a lookup made with that realm as the context. #13582 switched off visibility filtering for core extension realms only for JSR-330 beans (`setVisibilityPredicateSupplierTransformer`), not for Plexus `lookup()`, and 3.9.x had the same behaviour before it. Expected: lookups from a core extension behave the same whichever way the extension was loaded. A reproducer integration test follows in a pull request that links this issue. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
