CDI beans inside .jar are not found by the container (Unsatisfied dependencies)

Trying again after a while I've found the solution ─ I placed the beans.xml on the META-INF folder inside the project root folder and it worked! That's against the description of how to work with CDI beans inside jars on WELD documentation, where says the place to put beans.xml is inside src/main/resources/META-INF, but is okay. Maybe in some Maven projects, that's true.

[UPDATE] This works because I was building the jar using the export jar wizard of Eclipse instead of using Maven to do this. Using Maven should works fine with beans.xml in src/main/resources/META-INF.

Hope this can help others on this situation too.


I have faced with the same symptoms in Eclipse with two projects. WAR project injected implementations from imported JAR library project. Maven compiled all correctly, but during running in local run-time environment bean manager could not resolve library beans, was unstable and sent mentioned exceptions.

Eclipse does not use Maven for preparing code for debugging, and its Project Facets were configured with Maven plugin. Maven dependencies were matched in both projects, but problem was in Eclipse project configuration.

My environment was JBoss EAP 6.4, and I have found that Maven plugin set up JAR CDI project facets but left default version 2.0. Run-time supports CDI 1.0 actually, and CDI project facets in WAR project had correct version.

In my case different versions of CDI project facets in WAR and imported JAR projects led to this exception. Manual Eclipse project facets version correction is required. With matched CDI versions between run-time environment and Eclipse project facets problem is gone.