Hi,

Yes, maybe a bug in smallrye.

In the setup you deploy you scan smallrye-config so configproducer and the
extension in this jar adds configproducer with a custom identifier so owb
doesn't deduplicate the scanned and programmatic beans since they are
different for CDI.
One option is to exclude smallrye-config from the scanning or veto one of
the two beans with a custom extension.

Ideally smallrye should only add the bean if not found during the startup
IMHO as most CDI extensions do.

Romain Manni-Bucau
@rmannibucau <https://x.com/rmannibucau> | .NET Blog
<https://dotnetbirdie.github.io/> | Blog <https://rmannibucau.github.io/> | Old
Blog <http://rmannibucau.wordpress.com> | Github
<https://github.com/rmannibucau> | LinkedIn
<https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/en-us/product/java-ee-8-high-performance-9781788473064>


Le lun. 3 févr. 2025 à 12:59, Krzysztof Śmigrodzki <[email protected]> a
écrit :

> I've tried to use Microprofile Config in Java SE to inject configuration,
> but I was greeted by the following exception:
>
>
> Exception in thread "main"
> org.apache.webbeans.exception.WebBeansDeploymentException:
> jakarta.enterprise.inject.AmbiguousResolutionException: There is more than
> one Bean with type java.lang.String Qualifiers:
> [@org.eclipse.microprofile.config.inject.ConfigProperty(name="test.property",
> defaultValue="org.eclipse.microprofile.config.configproperty.unconfigureddvalue")]
> for injection into Field Injection Point, field name :  testProperty, Bean
> Owner : [OurBean, WebBeansType:MANAGED, Name:null, API
> Types:[java.lang.Object,me.noip.ksmigrod.spikes.cdiconfig.OurBean],
> Qualifiers:[jakarta.enterprise.inject.Default,jakarta.enterprise.inject.Any]]
> found beans:
> String, WebBeansType:PRODUCERMETHOD, Name:null, API
> Types:[java.io.Serializable,java.lang.CharSequence,java.lang.constant.ConstantDesc,java.lang.Comparable<String>,java.lang.String,java.lang.Object,java.lang.constant.Constable],
> Qualifiers:[jakarta.enterprise.inject.Any,org.eclipse.microprofile.config.inject.ConfigProperty],
> Producer Method: protected java.lang.String
> io.smallrye.config.inject.ConfigProducer.produceStringConfigProperty(jakarta.enterprise.inject.spi.InjectionPoint)
> from
> jar:file:/home/ksm/IdeaProjects/spikes/cdi-config/target/lib/smallrye-config-3.11.1.jar!/io/smallrye/config/inject/ConfigProducer.class
> String, WebBeansType:PRODUCERMETHOD, Name:null, API
> Types:[java.io.Serializable,java.lang.CharSequence,java.lang.constant.ConstantDesc,java.lang.Comparable<String>,java.lang.String,java.lang.Object,java.lang.constant.Constable],
> Qualifiers:[jakarta.enterprise.inject.Any,org.eclipse.microprofile.config.inject.ConfigProperty],
> Producer Method: protected java.lang.String
> io.smallrye.config.inject.ConfigProducer.produceStringConfigProperty(jakarta.enterprise.inject.spi.InjectionPoint)
> from
> jar:file:/home/ksm/IdeaProjects/spikes/cdi-config/target/lib/smallrye-config-3.11.1.jar!/io/smallrye/config/inject/ConfigProducer.class
>
> This message refers to the same metod of the same bean twice, which
> suggests a bug.
>
> I've made a minimal example of that error, and published it on github,
> README file for this project contains full stacktrace.
> https://github.com/ksmigrod/cdi-config/
>
> Project runs with Weld. The project builds with OpenWebBeans, but fails at
> runtime with AmbiguousResolutionException.
>
> Is it a bug in OWB, or is there something wrong with my code?
>
> Regards,
> Krzysztof Śmigrodzki
>

Reply via email to