CDI recognizes implicit bean archives

The Contexts and Dependency Injection (CDI) 1.1 specification introduced implicit bean discovery mode, resulting in behavior and performance changes from the Java Platform, Enterprise Edition (Java EE) 6 CDI 1.0 implementation in WebSphere Application Server. An implicit bean is any archive that contains one or more bean classes with either a bean-defining annotation or one or more session beans.

When moving from Java EE 6 CDI 1.0 to Java EE 7 CDI 1.1 or later, implicit bean discovery results in all WAR and JAR files being scanned by the runtime, even if they do not have a beans.xml file. This scan is a behavior change from Java EE 6 CDI 1.0, where a missing beans.xml file would prevent the scanning of archives in the application.

This rule flags the following bean-defining annotations and Enterprise JavaBeans (EJB) session beans in all WAR and JAR files that do not have a beans.xml file.

The binary application scanner flags annotation classes that are annotated as @NormalScope . Unlike the Eclipse-based application source scanner, it does not detect classes that are annotated with a normal scope type annotation. These annotations might be flagged outside of the scope of the beans.xml files that are using them either explicitly or implicitly.

To disable this CDI behavior change during run time at the WAR or JAR level, add a beans.xml file with bean discovery mode set to none, as shown in the following example.


<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="none" version="1.1">
</beans>

On Liberty, you can also disable this behavior by adding the following property to the server.xml file.


<cdi12 enableImplicitBeanArchives="false"/>

For more information on the Java EE 7 CDI 1.2 implementation, see Contexts and Dependency Injection 1.2 behavior changes.