Abhijit Sarkar
Abhijit Sarkar

Reputation: 24618

Weld cannot find CDI producer method in library jar

Using Wildfly 8.2.0.Final, which I believe uses Weld 2.2, I've reproduced this issue with 2 simple classes in a Maven multimodule project. One produces a javax.ws.rs.client.Client, another has an injection point for the same. Arquillian deployment fails with WELD-001408: unsatisfied dependencies. The producer is in a library jar that gets included in the WEB-INF/lib for the consumer. Producer has a beans.xml in the META-INF with discovery-mode=annotation and the consumer has one in WEB-INF with discovery-mode=all.

Steps to reproduce: Download this project and run mvn clean install from the root directory.

This is a critical bug. There're some other SO posts about Weld unsatisfied dependencies but most of them are because a beans.xml was missing. With CDI 1.2, beans.xml is optional, though my example does have couple. Any ideas?

Full disclosure: Also posted in Weld forum 255328

Upvotes: 2

Views: 1542

Answers (1)

Abhijit Sarkar
Abhijit Sarkar

Reputation: 24618

After days of trying to reproduce the issue in another project, but in vain, I reduced the original project to a CDI produce and a consumer and posted the code in JBoss forum and also opened a JIRA WELD-1921. Martin Kouba found out that the problem was caused by using the wrong Produces annotation! Instead of javax.enterprise.inject.Produces, I had javax.ws.rs.Produces. This obviously wasn't intentional and must've happened when I auto-imported the package in Eclipse and somehow picked the wrong one! There were some other issues too but nothing I couldn't solve myself. Thanks a ton Martin.

Upvotes: 5

Related Questions