If a beans.xml file includes decorators or interceptors, a valid schema must be used for proper instantiation. The namespace and schema location in the beans.xml file must match the specification for the applicable CDI version.
This rule scans beans.xml files to see if the
namespace provided in the xmlns attribute matches
the corresponding schema location on the schemaLocation attribute.
The following example shows a valid beans.xml file for the CDI 1.0 specification.
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
The following example shows a valid beans.xml file for the CDI 1.2 specification.
<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" version="1.1">
</beans>
If no namespace is provided, the rule does not flag the beans.xml file.
The automated fix for this rule updates incompatible namespaces with the value appropriate to the specified schemaLocation. Copy the custom configuration to your application build file to enable the fix automation.
If you are considering using CDI 1.2 provided with Java EE 7, see Contexts and Dependency Injection 1.2 behavior changes.