If a beans.xml file includes decorators or interceptors, a valid schema must be used for proper instantiation. The namespace in the beans.xml file must match the specification for the applicable CDI version.
This rule scans beans.xml files to see if a
valid namespace is provided on the xmlns 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 a namespace is provided and it does not match either specification, the server throws an exception when processing the beans.xml file. You can disable validation by setting the following JVM property:
org.jboss.weld.xml.disableValidating=true
If no namespace is provided, the rule does not flag the beans.xml file.
If you are considering using CDI 1.2 provided with Java EE 7, see Contexts and Dependency Injection 1.2 behavior changes.