CDI problem using a dependency on a module
matthieu.brouillard Mar 24, 2015 5:53 AMHi all,
I don't know if the problem I am facing is a weld/jboss-modules/wildfly or miss-usage problem so I post in this "general" forum.
I tried to simplify as much as I could my problem and before opening an issue I wanted to have some review if I didn't perform something wrong.
I have a library containing:
- an interface: PrefixProvider
- a CDI producer producing an implementation of this interface
- 2 pojos implementing this interface and annotated @Vetoed so that only the producer should be considered for CDI
If I package this lib into a war, everything works as expected (see project prefix-app-embedded), a call to my REST endpoint returns correctly with the CDI injection point being resolved correctly and the @Vetoed considered.
curl http://localhost:8080/app-e/resources/password
defaultccc8997c-4a92-47de-ab4a-17f62dc2e620
If I package this lib as a module, and reference it inside a war via a manifest dependency with meta-inf (see project prefix-app-module-dep) I cannot deploy the application because of CDI errors due to ambiguous dependencies as if the classes were not annotated.
2015-03-24 10:07:51,706 ERROR [org.jboss.as.controller.management-operation] ..... skipped .....
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type PrefixProvider with qualifiers @Default
at injection point [UnbackedAnnotatedField] @Inject com.agfa.wildfly.prefix.PasswordResources.prefixProvider
at com.agfa.wildfly.prefix.PasswordResources.prefixProvider(PasswordResources.java:0)
Possible dependencies:
- Managed Bean [class com.agfa.wildfly.prefix.RandomPrefixProvider] with qualifiers [@Any @Default],
- Producer Method [PrefixProvider] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces public com.agfa.wildfly.prefix.PrefixProviderProducer.produces()],
- Managed Bean [class com.agfa.wildfly.prefix.FixedPrefixProvider] with qualifiers [@Any @Default]
I must admit I do not understand the described behavior.
I also tried several other things, including:
- removing in my module the dependency to javax.enterprise.api
- exporting in my module the dependency to javax.enterprise.api
- removing the meta-inf in my manifest dependency
All of those actions ended in also CDI deployment errors BUT this time only on the 2 classes.
I am using wildfly 8.2.0-final.
-
weld-jboss-modules-pb.zip 36.9 KB