Hey,
I am currently trying to see whether I can use the junit5 openwebbeans
extension for my testing needs. One use-case is that I need to be able
to use beans which have been declared somewhere on the classpath. My
understanding of the documentation and the comments on the annotation is
that this should happen in the default behavior, more specifically when
`disableDiscovery=false` is set in the `@Cdi` annotation. I was however
unable to get this to work. To debug this I had a look at your internal
tests for the cdi extension, but if I didn't miss anything only the
behavior with `disableDiscovery=true` is currently being tested. I then
tried to add a simple unit-test for the case that discovery is enabled
(https://github.com/cortlepp/openwebbeans/tree/cdi-junit-enable-discovery)
but failed.
If I run the test individually, I get the following error:
```
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.openwebbeans.junit5.discovery.CdiDiscoveryTest
Nov 25, 2025 11:19:12 AM org.apache.webbeans.lifecycle.AbstractLifeCycle
bootstrapApplication
INFO: OpenWebBeans Container is starting...
Nov 25, 2025 11:19:12 AM
org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery
addWebBeansXmlLocation
INFO: added beans archive URL:
file:/home/cortlepp/code/openwebbeans/webbeans-junit5/target/test-classes/META-INF/beans.xml
Nov 25, 2025 11:19:12 AM
org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery
addWebBeansXmlLocation
INFO: added beans archive URL:
file:/home/cortlepp/code/openwebbeans/webbeans-junit5/target/classes/META-INF/beans.xml
Nov 25, 2025 11:19:12 AM
org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery
addWebBeansXmlLocation
INFO: added beans archive URL:
jar:file:/home/cortlepp/.m2/repository/org/apache/maven/surefire/common-java5/3.2.2/common-java5-3.2.2.jar!/
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
0.228 s <<< FAILURE! -- in
org.apache.openwebbeans.junit5.discovery.CdiDiscoveryTest
[ERROR] org.apache.openwebbeans.junit5.discovery.CdiDiscoveryTest --
Time elapsed: 0.228 s <<< ERROR!
org.apache.webbeans.exception.WebBeansDeploymentException:
jakarta.enterprise.inject.UnsatisfiedResolutionException: Api type
[org.apache.openwebbeans.junit5.features.AlternativeTest$Provider] is
not found with the qualifiers
Qualifiers: [@jakarta.enterprise.inject.Default()]
for injection into Field Injection Point, field name : provider, Bean
Owner : [Service, WebBeansType:MANAGED, Name:null, API
Types:[java.lang.Object,org.apache.openwebbeans.junit5.features.AlternativeTest$Service],
Qualifiers:[jakarta.enterprise.inject.Default,jakarta.enterprise.inject.Any]]
at
org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:399)
at
org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(AbstractLifeCycle.java:137)
at
org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:103)
at
org.apache.openwebbeans.se.OWBInitializer.newContainer(OWBInitializer.java:128)
at
org.apache.openwebbeans.se.OWBInitializer.initialize(OWBInitializer.java:113)
at
org.apache.openwebbeans.se.SeInitializerFacade.initialize(SeInitializerFacade.java:177)
at
org.apache.openwebbeans.junit5.internal.CdiExtension.beforeAll(CdiExtension.java:104)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Api
type [org.apache.openwebbeans.junit5.features.AlternativeTest$Provider]
is not found with the qualifiers
Qualifiers: [@jakarta.enterprise.inject.Default()]
for injection into Field Injection Point, field name : provider, Bean
Owner : [Service, WebBeansType:MANAGED, Name:null, API
Types:[java.lang.Object,org.apache.openwebbeans.junit5.features.AlternativeTest$Service],
Qualifiers:[jakarta.enterprise.inject.Default,jakarta.enterprise.inject.Any]]
at
org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
at
org.apache.webbeans.container.InjectionResolver.checkInjectionPoint(InjectionResolver.java:241)
at
org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1240)
at
org.apache.webbeans.util.WebBeansUtil.validate(WebBeansUtil.java:1509)
at
org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:1269)
at
org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:1180)
at
org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:324)
... 7 more
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] CdiDiscoveryTest » WebBeansDeployment
jakarta.enterprise.inject.UnsatisfiedResolutionException: Api type
[org.apache.openwebbeans.junit5.features.AlternativeTest$Provider] is
not found with the qualifiers
Qualifiers: [@jakarta.enterprise.inject.Default()]
for injection into Field Injection Point, field name : provider, Bean
Owner : [Service, WebBeansType:MANAGED, Name:null, API
Types:[java.lang.Object,org.apache.openwebbeans.junit5.features.AlternativeTest$Service],
Qualifiers:[jakarta.enterprise.inject.Default,jakarta.enterprise.inject.Any]]
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
```
And when I run all tests in the module the errors get even stranger:
```
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] CdiParameterResolversTest.start:50 » IllegalArgument
jdk.internal.loader.ClassLoaders$AppClassLoader@30946e09 is already
registered
[ERROR] CdiWithOnStartTest » IllegalArgument
jdk.internal.loader.ClassLoaders$AppClassLoader@30946e09 is already
registered
[ERROR] ScopesTest » IllegalArgument
jdk.internal.loader.ClassLoaders$AppClassLoader@30946e09 is already
registered
[ERROR] CdiDiscoveryTest » WebBeansDeployment
jakarta.enterprise.inject.UnsatisfiedResolutionException: Api type
[org.apache.openwebbeans.junit5.features.AlternativeTest$Provider] is
not found with the qualifiers
Qualifiers: [@jakarta.enterprise.inject.Default()]
for injection into Field Injection Point, field name : provider, Bean
Owner : [Service, WebBeansType:MANAGED, Name:null, API
Types:[java.lang.Object,org.apache.openwebbeans.junit5.features.AlternativeTest$Service],
Qualifiers:[jakarta.enterprise.inject.Default,jakarta.enterprise.inject.Any]]
[ERROR] AlternativeTest » IllegalArgument
jdk.internal.loader.ClassLoaders$AppClassLoader@30946e09 is already
registered
[ERROR] InterceptorTest » IllegalArgument
jdk.internal.loader.ClassLoaders$AppClassLoader@30946e09 is already
registered
[ERROR] ParameterResolutionTest » IllegalArgument
jdk.internal.loader.ClassLoaders$AppClassLoader@30946e09 is already
registered
```
So my question is: am I using the extension wrong or is it just broken
currently?
Best,
Christian