On Tue, Jul 22, 2025 at 4:51 PM Matej Novotny <manovotn(a)redhat.com> wrote:
On Tue, Jul 22, 2025 at 3:39 PM Scott Marlow <smarlow(a)redhat.com> wrote:
> Note that we may of lost some recent email messages but I think the below
> contains them. Responding inline...
>
> On Tue, Jul 22, 2025 at 6:06 AM Matej Novotny <manovotn(a)redhat.com>
> wrote:
>
>> Right, sorry - you need an instance of Annotation and have just a
>> Class<? extends Annotation>, my bad.
>> I checked the code and did my homework on how you get to these
>> qualifiers and why they come as Strings and now I see that the solution you
>> have is good, sorry for the noise.
>>
>
> Thank you for the clarification!
>
> Would it make sense for a future release of Weld to include
> the ScopeProxy class in some form from
>
https://github.com/scottmarlow/wildfly/pull/36? Direct pointer to
> the ScopeProxy
>
https://github.com/scottmarlow/wildfly/pull/36/files#diff-9d21579f8a3180d...
>
> James Perkins mentioned that we have the same class in three places now
> so perhaps it could be shared via Weld? I'm not really sure if that makes
> sense or not.
>
Hm, perhaps in the weld/api project?
But I am frankly not sure it is a good place - it might be a better fit
for some "annotations" or utils project but Weld doesn't have any such.
What are the other places where this is used? Is it always linked to
Weld/CDI? If so, then it might make sense but on paper it looks like a more
general problem.
>
>
>>
>> BTW, the specification says this can be basically any Qualifier, but it
>> doesn't seem to cover qualifiers with binding values
>> (@SomeQualifier("foo")).
>> In such a case, you cannot really know what member value to use. Maybe
>> those should be detected and an exception thrown?
>>
>
> Hmm, that would be helpful. Would WildFly just check if certain
> unsupported characters are included in the qualifier? Perhaps
> single/double quote.
>
I am not talking about unsupported characters - what I mean is that the
ScopeProxy cannot really create a proxy of an annotation with members.
You assume that the annotation you create either has no members or has
default values that you attempt to return as best effort.
In CDI, those members can (but don't have to) be binding meaning a bean
MyBean @SomeQualifier("foo") is not the same as MyBean
@SomeQualifier("bar").
See
also
https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#qualifier_...
>
> Scott
>
>
>>
>> Matej
>>
>> On Mon, Jul 21, 2025 at 6:36 PM Scott Marlow <smarlow(a)redhat.com> wrote:
>>
>>>
>>>
>>> On Mon, Jul 21, 2025 at 11:12 AM Matej Novotny <manovotn(a)redhat.com>
>>> wrote:
>>>
>>>> Hi and sorry for the late answer, I was away the last few days.
>>>>
>>>> Indeed, you were adding the @Qualifier annotation instead of the
>>>> actual qualifier.
>>>> From the PR you shared, I am not sure what's the point of
>>>> using ScopeProxy though.
>>>> It appears that adding the qualifier the following way would do the
>>>> trick as well?
>>>>
>>>> >
>>>>
beanConfigurator.addQualifier(persistenceUnitMetadata.getClassLoader().loadClass(qualifier).asSubclass(Annotation.class);
>>>>
>>>
>>> I tried a few variations of that change but it seems more changes are
>>> needed:
>>>
>>> Switched to:
>>>
>>> final Class<? extends Annotation> qualifierType =
>>> persistenceUnitMetadata.getClassLoader()
>>> .loadClass(qualifier)
>>> .asSubclass(Annotation.class);
>>> beanConfigurator.addQualifier(qualifierType);
>>>
>>> Compile failure is:
>>>
>>>
wildfly/jpa/subsystem/src/main/java/org/jboss/as/jpa/beanmanager/PersistenceIntegrationWithCDI.java:[111,47]
>>> incompatible types: java.lang.Class<capture#1 of ? extends
>>> java.lang.annotation.Annotation> cannot be converted to
>>> java.lang.annotation.Annotation
>>>
>>> Intellij IDE shows failure:
>>>
>>> Required type:
>>> Annotation
>>>
>>> Provided:
>>> Class
>>> <capture of ? extends Annotation>
>>>
>>> Any suggestions?
>>>
>>> Thanks,
>>> Scott
>>>
>>>
>>>>
>>>> Matej
>>>>
>>>> On Fri, Jul 18, 2025 at 2:42 AM Scott Marlow via weld-dev <
>>>> weld-dev(a)lists.jboss.org> wrote:
>>>>
>>>>> James Perkins already answered my question by creating pull request
>>>>>
https://github.com/scottmarlow/wildfly/pull/36 to correct the [1]
>>>>> code.
>>>>>
>>>>> Scott
>>>>>
>>>>> On Thu, Jul 17, 2025 at 1:18 PM Scott Marlow
<smarlow(a)redhat.com>
>>>>> wrote:
>>>>>
>>>>>> Any suggestions for what is wrong in [1] that
>>>>>> causes org.jboss.weld.util.Bindings#validateQualifiers() to
throw
>>>>>> "MetadataLogger.LOG.notAQualifier" error [2]?
>>>>>>
>>>>>> I tried a few variations of loading an application class that
should
>>>>>> be a jakarta.inject.Qualifier but doesn't seem to work
correctly.
>>>>>>
>>>>>> In summary, I'm trying to implement the [3] feature that
integrates
>>>>>> Persistence + CDI access from a Jakarta EE 11 implementation.
>>>>>>
>>>>>> Thanks,
>>>>>> Scott
>>>>>>
>>>>>> [1]
>>>>>>
https://github.com/wildfly/wildfly/compare/main...scottmarlow:wildfly:WFL...
>>>>>>
>>>>>> [2]
>>>>>> 2025-07-17 12:55:53,714 INFO [org.jboss.as.jpa] (ServerService
>>>>>> Thread Pool -- 84) WFLYJPA0010: Starting Persistence Unit (phase
2 of 2)
>>>>>> Service 'CDIPersistenceTestCase.jar#pu1'
>>>>>> 2025-07-17 12:55:54,364 ERROR [org.jboss.msc.service.fail] (MSC
>>>>>> service thread 1-6) MSC000001: Failed to start service
>>>>>>
jboss.deployment.unit."CDIPersistenceTestCase.jar".WeldStartService:
>>>>>> org.jboss.msc.service.StartException in service
>>>>>>
jboss.deployment.unit."CDIPersistenceTestCase.jar".WeldStartService: Failed
>>>>>> to start service
>>>>>> at org.jboss.msc(a)1.5.6.Final
>>>>>>
//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1545)
>>>>>> at org.jboss.msc(a)1.5.6.Final
>>>>>>
//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1374)
>>>>>> at org.jboss.threads(a)3.9.1
>>>>>>
//org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
>>>>>> at org.jboss.threads(a)3.9.1
>>>>>>
//org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
>>>>>> at org.jboss.threads(a)3.9.1
>>>>>>
//org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
>>>>>> at org.jboss.threads(a)3.9.1
>>>>>>
//org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
>>>>>> at org.jboss.threads(a)3.9.1
>>>>>>
//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
>>>>>> at java.base/java.lang.Thread.run(Thread.java:840)
>>>>>> Caused by: jakarta.enterprise.inject.spi.DefinitionException:
>>>>>> org.jboss.weld.exceptions.DefinitionException: WELD-001111:
interface
>>>>>> jakarta.inject.Qualifier defined on Configurator Bean [interface
>>>>>> jakarta.persistence.EntityManager, types: Object, EntityManager,
>>>>>> qualifiers: @Any @Qualifier] is not a qualifier
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.finish(AfterBeanDiscoveryImpl.java:200)
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:76)
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:463)
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:87)
>>>>>> at org.jboss.as.weld(a)37.0.0.Final-SNAPSHOT
>>>>>>
//org.jboss.as.weld.WeldStartService.start(WeldStartService.java:80)
>>>>>> at org.jboss.msc(a)1.5.6.Final
>>>>>>
//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1553)
>>>>>> at org.jboss.msc(a)1.5.6.Final
>>>>>>
//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1516)
>>>>>> ... 7 more
>>>>>> Caused by: org.jboss.weld.exceptions.DefinitionException:
>>>>>> WELD-001111: interface jakarta.inject.Qualifier defined on
Configurator
>>>>>> Bean [interface jakarta.persistence.EntityManager, types:
Object,
>>>>>> EntityManager, qualifiers: @Any @Qualifier] is not a qualifier
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.util.Bindings.validateQualifiers(Bindings.java:77)
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bean.attributes.ExternalBeanAttributesFactory.validateQualifiers(ExternalBeanAttributesFactory.java:89)
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bean.attributes.ExternalBeanAttributesFactory.validateBeanAttributes(ExternalBeanAttributesFactory.java:71)
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.processBeanRegistration(AfterBeanDiscoveryImpl.java:212)
>>>>>> at org.jboss.weld.core(a)5.1.6.Final
>>>>>>
//org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.finish(AfterBeanDiscoveryImpl.java:194)
>>>>>> ... 13 more
>>>>>>
>>>>>> [3]
>>>>>>
https://jakarta.ee/specifications/platform/11/jakarta-platform-spec-11.0#...
>>>>>>
>>>>> _______________________________________________
>>>>> weld-dev mailing list -- weld-dev(a)lists.jboss.org
>>>>> To unsubscribe send an email to weld-dev-leave(a)lists.jboss.org
>>>>> Privacy Statement:
https://www.redhat.com/en/about/privacy-policy
>>>>> List Archives:
>>>>>
https://lists.jboss.org/archives/list/weld-dev@lists.jboss.org/message/JE...
>>>>>
>>>>