When Your DI Breaks: bean-discovery-mode in CDI 1.1 (JavaEE 7)
CDI 1.1 JSR-346 comes with finer scanning control and an
bean-discovery-mode with possible values:
<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_1.xsd" bean-discovery-mode="all"> </beans>
However, the suggested value "annotated" only recognizes annotated CDI managed beans. Beans without any annotation are ignored.
all behaves like in Java EE 6: also beans without any annotations are recognized.
So if DI doesn't work (e.g.
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type…), double check the
See you at Java EE Workshops at MUC Airport!
If the cure is more XML, does it cross anybody's mind that the disease is XML?
Posted by Tim Boudreau on July 11, 2013 at 02:24 PM CEST #
Can you help me fix the issue ?
I am using GF4 and created a class in application client jar and trying to inject it into EJB module and Web mobule. but i am getting below exception.
Posted by krishna kodali on August 04, 2013 at 07:01 AM CEST #
Is it possible to @Inject String (having @Produces method defined elsewhere) while bean-discovery-mode is set to annotated???? Of course JavaEE7 and GF4.0.
Posted by Bartek on August 05, 2013 at 05:30 PM CEST #
It is surprising that CDI expert committee completely overlooked the necessity to manually register beans or specify beans.xml file from alternative locations, or specify jar-file paths in one beans.xml.
This would have reduced the need for a lot of boiler plate code to make classes outside the established JEE deployment structure available as CDI beans.
I hope at least JEE-8 fixes this shortcoming, and makes manual registration of CDI beans simpler.
Posted by Samba Kolusu on August 06, 2015 at 07:57 PM CEST #
ho can i define Alternatives across jars... by default the alternative only works for the beans in current jar. is there any annotation or some option in beans.xml.. (i m new to this thing). thanks
Posted by manoj on July 08, 2016 at 11:55 AM CEST #