UnsatisfiedResolutionException with qualifiers -- what am I doing wrong?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

UnsatisfiedResolutionException with qualifiers -- what am I doing wrong?

Emmanuel Touzery-2
Hello,

     I'm confused about a CDI error, I would expect this to work... What
am I doing wrong? It's true otherwise that the interface is defined in
another JAR than the producer but I wouldn't expect it to be a problem...

     At runtime I get:

08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans
module deployment failed
  org.apache.webbeans.exception.WebBeansDeploymentException:
javax.enterprise.inject.UnsatisfiedResolutionException: Api type
[com.lecip.core.application.customer_profiles.CustomerProfile] is not
found with the qualifiers
Qualifiers:
[@com.lecip.core.application.customer_profiles.CustomerContext()]
for injection into Field Injection Point, field name : _customerProfile,
Bean Owner : [TmsAllFunctionalitiesProvider, WebBeansType:MANAGED,
Name:null, API
Types:[java.lang.Object,com.lecip.tms.tms_core.authorization.TmsAllFunctionalitiesProvider,com.lecip.core.authorization.AllFunctionalitiesProvider],
Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]

     Any ideas?

--- beans.xml --

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
        version="1.2" bean-discovery-mode="all">
</beans>

-- CustomerContext.java --

@Qualifier
@Retention(RUNTIME)
@Target({TYPE, METHOD, FIELD, PARAMETER})
public @interface CustomerContext {}

-- CustomerProfileProducer.java --

public class CustomerProfileProducer {
     @Produces
     @CustomerContext
      public CustomerProfile getCustomerProfile() {
          return null;
    }
}

  -- Injecting class --

     @Inject @CustomerContext
     CustomerProfile customerProfile;

Reply | Threaded
Open this post in threaded view
|

Re: UnsatisfiedResolutionException with qualifiers -- what am I doing wrong?

Romain Manni-Bucau
Hi Emmanuel,

did you check your jar was not in the default excludes? (try renaming it
"foo.jar" to test quickly)


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

2018-03-08 13:32 GMT+01:00 Emmanuel Touzery <
[hidden email]>:

> Hello,
>
>     I'm confused about a CDI error, I would expect this to work... What am
> I doing wrong? It's true otherwise that the interface is defined in another
> JAR than the producer but I wouldn't expect it to be a problem...
>
>     At runtime I get:
>
> 08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
> org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans module
> deployment failed
>  org.apache.webbeans.exception.WebBeansDeploymentException:
> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
> com.lecip.core.application.customer_profiles.CustomerProfile] is not
> found with the qualifiers
> Qualifiers: [@com.lecip.core.application.customer_profiles.CustomerConte
> xt()]
> for injection into Field Injection Point, field name : _customerProfile,
> Bean Owner : [TmsAllFunctionalitiesProvider, WebBeansType:MANAGED,
> Name:null, API Types:[java.lang.Object,com.le
> cip.tms.tms_core.authorization.TmsAllFunctionalitiesProvider
> ,com.lecip.core.authorization.AllFunctionalitiesProvider],
> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
>
>     Any ideas?
>
> --- beans.xml --
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
>        version="1.2" bean-discovery-mode="all">
> </beans>
>
> -- CustomerContext.java --
>
> @Qualifier
> @Retention(RUNTIME)
> @Target({TYPE, METHOD, FIELD, PARAMETER})
> public @interface CustomerContext {}
>
> -- CustomerProfileProducer.java --
>
> public class CustomerProfileProducer {
>     @Produces
>     @CustomerContext
>      public CustomerProfile getCustomerProfile() {
>          return null;
>    }
> }
>
>  -- Injecting class --
>
>     @Inject @CustomerContext
>     CustomerProfile customerProfile;
>
>
Reply | Threaded
Open this post in threaded view
|

Re: UnsatisfiedResolutionException with qualifiers -- what am I doing wrong?

Emmanuel Touzery-2
Hello,

     thank you for the answer! No, definitely it's not in the default
excludes. Already injecting bunch of things from that JAR. Also, the
interface is in a JAR, but the producer is in the main code of the app.
And it's the producer which can't be found.
     From your answer I take it that it should work :-(

emmanuel

On 08/03/18 14:12, Romain Manni-Bucau wrote:

> Hi Emmanuel,
>
> did you check your jar was not in the default excludes? (try renaming it
> "foo.jar" to test quickly)
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
> 2018-03-08 13:32 GMT+01:00 Emmanuel Touzery <
> [hidden email]>:
>
>> Hello,
>>
>>      I'm confused about a CDI error, I would expect this to work... What am
>> I doing wrong? It's true otherwise that the interface is defined in another
>> JAR than the producer but I wouldn't expect it to be a problem...
>>
>>      At runtime I get:
>>
>> 08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
>> org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans module
>> deployment failed
>>   org.apache.webbeans.exception.WebBeansDeploymentException:
>> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
>> com.lecip.core.application.customer_profiles.CustomerProfile] is not
>> found with the qualifiers
>> Qualifiers: [@com.lecip.core.application.customer_profiles.CustomerConte
>> xt()]
>> for injection into Field Injection Point, field name : _customerProfile,
>> Bean Owner : [TmsAllFunctionalitiesProvider, WebBeansType:MANAGED,
>> Name:null, API Types:[java.lang.Object,com.le
>> cip.tms.tms_core.authorization.TmsAllFunctionalitiesProvider
>> ,com.lecip.core.authorization.AllFunctionalitiesProvider],
>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
>>
>>      Any ideas?
>>
>> --- beans.xml --
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>> http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
>>         version="1.2" bean-discovery-mode="all">
>> </beans>
>>
>> -- CustomerContext.java --
>>
>> @Qualifier
>> @Retention(RUNTIME)
>> @Target({TYPE, METHOD, FIELD, PARAMETER})
>> public @interface CustomerContext {}
>>
>> -- CustomerProfileProducer.java --
>>
>> public class CustomerProfileProducer {
>>      @Produces
>>      @CustomerContext
>>       public CustomerProfile getCustomerProfile() {
>>           return null;
>>     }
>> }
>>
>>   -- Injecting class --
>>
>>      @Inject @CustomerContext
>>      CustomerProfile customerProfile;
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: UnsatisfiedResolutionException with qualifiers -- what am I doing wrong?

Romain Manni-Bucau
yes, try reproducing it in a sample maybe


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

2018-03-08 14:20 GMT+01:00 Emmanuel Touzery <
[hidden email]>:

> Hello,
>
>     thank you for the answer! No, definitely it's not in the default
> excludes. Already injecting bunch of things from that JAR. Also, the
> interface is in a JAR, but the producer is in the main code of the app. And
> it's the producer which can't be found.
>     From your answer I take it that it should work :-(
>
> emmanuel
>
> On 08/03/18 14:12, Romain Manni-Bucau wrote:
>
>> Hi Emmanuel,
>>
>> did you check your jar was not in the default excludes? (try renaming it
>> "foo.jar" to test quickly)
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <https://rmannibucau.metawerx.net/> | Old Blog
>> <http://rmannibucau.wordpress.com> | Github <
>> https://github.com/rmannibucau> |
>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
>> <https://www.packtpub.com/application-development/java-ee-8-
>> high-performance>
>>
>>
>> 2018-03-08 13:32 GMT+01:00 Emmanuel Touzery <
>> [hidden email]>:
>>
>> Hello,
>>>
>>>      I'm confused about a CDI error, I would expect this to work... What
>>> am
>>> I doing wrong? It's true otherwise that the interface is defined in
>>> another
>>> JAR than the producer but I wouldn't expect it to be a problem...
>>>
>>>      At runtime I get:
>>>
>>> 08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
>>> org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans
>>> module
>>> deployment failed
>>>   org.apache.webbeans.exception.WebBeansDeploymentException:
>>> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
>>> com.lecip.core.application.customer_profiles.CustomerProfile] is not
>>> found with the qualifiers
>>> Qualifiers: [@com.lecip.core.application.customer_profiles.CustomerConte
>>> xt()]
>>> for injection into Field Injection Point, field name : _customerProfile,
>>> Bean Owner : [TmsAllFunctionalitiesProvider, WebBeansType:MANAGED,
>>> Name:null, API Types:[java.lang.Object,com.le
>>> cip.tms.tms_core.authorization.TmsAllFunctionalitiesProvider
>>> ,com.lecip.core.authorization.AllFunctionalitiesProvider],
>>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise
>>> .inject.Any]]
>>>
>>>      Any ideas?
>>>
>>> --- beans.xml --
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>>>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>>> http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
>>>         version="1.2" bean-discovery-mode="all">
>>> </beans>
>>>
>>> -- CustomerContext.java --
>>>
>>> @Qualifier
>>> @Retention(RUNTIME)
>>> @Target({TYPE, METHOD, FIELD, PARAMETER})
>>> public @interface CustomerContext {}
>>>
>>> -- CustomerProfileProducer.java --
>>>
>>> public class CustomerProfileProducer {
>>>      @Produces
>>>      @CustomerContext
>>>       public CustomerProfile getCustomerProfile() {
>>>           return null;
>>>     }
>>> }
>>>
>>>   -- Injecting class --
>>>
>>>      @Inject @CustomerContext
>>>      CustomerProfile customerProfile;
>>>
>>>
>>>
>
Reply | Threaded
Open this post in threaded view
|

Re: UnsatisfiedResolutionException with qualifiers -- what am I doing wrong?

Emmanuel Touzery-2
Hi,

        finally tracked it down to a <packagingExcludes> clause in the
pom.xml...

     Thank you!

Emmanuel

On 08/03/18 14:23, Romain Manni-Bucau wrote:

> yes, try reproducing it in a sample maybe
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
> 2018-03-08 14:20 GMT+01:00 Emmanuel Touzery <
> [hidden email]>:
>
>> Hello,
>>
>>      thank you for the answer! No, definitely it's not in the default
>> excludes. Already injecting bunch of things from that JAR. Also, the
>> interface is in a JAR, but the producer is in the main code of the app. And
>> it's the producer which can't be found.
>>      From your answer I take it that it should work :-(
>>
>> emmanuel
>>
>> On 08/03/18 14:12, Romain Manni-Bucau wrote:
>>
>>> Hi Emmanuel,
>>>
>>> did you check your jar was not in the default excludes? (try renaming it
>>> "foo.jar" to test quickly)
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>> <https://rmannibucau.metawerx.net/> | Old Blog
>>> <http://rmannibucau.wordpress.com> | Github <
>>> https://github.com/rmannibucau> |
>>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
>>> <https://www.packtpub.com/application-development/java-ee-8-
>>> high-performance>
>>>
>>>
>>> 2018-03-08 13:32 GMT+01:00 Emmanuel Touzery <
>>> [hidden email]>:
>>>
>>> Hello,
>>>>       I'm confused about a CDI error, I would expect this to work... What
>>>> am
>>>> I doing wrong? It's true otherwise that the interface is defined in
>>>> another
>>>> JAR than the producer but I wouldn't expect it to be a problem...
>>>>
>>>>       At runtime I get:
>>>>
>>>> 08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
>>>> org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans
>>>> module
>>>> deployment failed
>>>>    org.apache.webbeans.exception.WebBeansDeploymentException:
>>>> javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
>>>> com.lecip.core.application.customer_profiles.CustomerProfile] is not
>>>> found with the qualifiers
>>>> Qualifiers: [@com.lecip.core.application.customer_profiles.CustomerConte
>>>> xt()]
>>>> for injection into Field Injection Point, field name : _customerProfile,
>>>> Bean Owner : [TmsAllFunctionalitiesProvider, WebBeansType:MANAGED,
>>>> Name:null, API Types:[java.lang.Object,com.le
>>>> cip.tms.tms_core.authorization.TmsAllFunctionalitiesProvider
>>>> ,com.lecip.core.authorization.AllFunctionalitiesProvider],
>>>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise
>>>> .inject.Any]]
>>>>
>>>>       Any ideas?
>>>>
>>>> --- beans.xml --
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>>>>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>>>> http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
>>>>          version="1.2" bean-discovery-mode="all">
>>>> </beans>
>>>>
>>>> -- CustomerContext.java --
>>>>
>>>> @Qualifier
>>>> @Retention(RUNTIME)
>>>> @Target({TYPE, METHOD, FIELD, PARAMETER})
>>>> public @interface CustomerContext {}
>>>>
>>>> -- CustomerProfileProducer.java --
>>>>
>>>> public class CustomerProfileProducer {
>>>>       @Produces
>>>>       @CustomerContext
>>>>        public CustomerProfile getCustomerProfile() {
>>>>            return null;
>>>>      }
>>>> }
>>>>
>>>>    -- Injecting class --
>>>>
>>>>       @Inject @CustomerContext
>>>>       CustomerProfile customerProfile;
>>>>
>>>>
>>>>