O'Reilly logo

Mastering Java EE Development with WildFly by Luca Stancapiano

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enabled and disabled beans

In WildFly, injection is enabled by the XML descriptor. For example if you are in a web application, you deploy web.xml, and in EJB, ejb-jar.xml. Considering that these descriptors are now optional, the same thing is not true for the CDI. If you don’t deploy an almost empty XML descriptor, CDI doesn’t work because the CDI engine is not started. For a simple CDI injection you must also deploy the standard beans descriptor, the beans.xml. Here is an empty sample of beans.xml that lets the CDI engine to start:

 <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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required