Discussion:
UnsatisfiedResolutionException with qualifiers -- what am I doing wrong?
Emmanuel Touzery
2018-03-08 12:32:28 UTC
Permalink
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;
Romain Manni-Bucau
2018-03-08 13:12:32 UTC
Permalink
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 <
Post by Emmanuel Touzery
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...
08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans module
deployment failed
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
com.lecip.core.application.customer_profiles.CustomerProfile] is not
found with the qualifiers
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})
-- CustomerProfileProducer.java --
public class CustomerProfileProducer {
@Produces
@CustomerContext
public CustomerProfile getCustomerProfile() {
return null;
}
}
-- Injecting class --
@Inject @CustomerContext
CustomerProfile customerProfile;
Emmanuel Touzery
2018-03-08 13:20:14 UTC
Permalink
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
Post by 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 <
Post by Emmanuel Touzery
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...
08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans module
deployment failed
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
com.lecip.core.application.customer_profiles.CustomerProfile] is not
found with the qualifiers
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})
-- CustomerProfileProducer.java --
public class CustomerProfileProducer {
@Produces
@CustomerContext
public CustomerProfile getCustomerProfile() {
return null;
}
}
-- Injecting class --
@Inject @CustomerContext
CustomerProfile customerProfile;
Romain Manni-Bucau
2018-03-08 13:23:28 UTC
Permalink
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 <
Post by Emmanuel Touzery
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
Post by 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 <
Hello,
Post by Emmanuel Touzery
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...
08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans module
deployment failed
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
com.lecip.core.application.customer_profiles.CustomerProfile] is not
found with the qualifiers
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})
-- CustomerProfileProducer.java --
public class CustomerProfileProducer {
@Produces
@CustomerContext
public CustomerProfile getCustomerProfile() {
return null;
}
}
-- Injecting class --
@Inject @CustomerContext
CustomerProfile customerProfile;
Emmanuel Touzery
2018-03-09 09:47:11 UTC
Permalink
Hi,

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

    Thank you!

Emmanuel
Post by 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 <
Post by Emmanuel Touzery
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
Post by 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 <
Hello,
Post by Emmanuel Touzery
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...
08-Mar-2018 12:27:57.287 SEVERE [localhost-startStop-1]
org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans module
deployment failed
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [
com.lecip.core.application.customer_profiles.CustomerProfile] is not
found with the qualifiers
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})
-- CustomerProfileProducer.java --
public class CustomerProfileProducer {
@Produces
@CustomerContext
public CustomerProfile getCustomerProfile() {
return null;
}
}
-- Injecting class --
@Inject @CustomerContext
CustomerProfile customerProfile;
Loading...