The target platform for CDI (JSR-346) is Java EE. However, Weld also supports Tomcat and Jetty servlet containers for a long time (even if the level of support is limited). Up to now, Weld was using the "flat deployment structure", i.e. all bean classes shared the same bean archive and all
beans.xml descriptors are automatically merged into one. Thus alternatives, interceptors and decorators selected/enabled for a bean archive were enabled for an application. Of course, this is not correct per the spec. Moreover, CDI 1.1 introduced new types of bean discovery for implicit bean archives -
none (see also Section 15.6, “Packaging and deployment” and Bean archives in CDI 1.1). Weld Servlet did not support this either and so all classes were always discovered.
Since version 2.2.5.Final, the bean archive isolation is enabled by default. So the only way to select/enable alternatives, interceptors and decorators for an application is to use
@javax.annotation.Priority. Also implicit bean archives with
are handled correctly. As a bonus, Weld Servlet supports the use of Jandex bytecode scanning library to speed up the scanning process - simply put the jandex.jar on the classpath.
We are aware that the bean isolation could break some old applications. Therefore, the default behaviour can be changed (enforcing the use of the "flat deployment structure") by setting the servlet initialization parameter
org.jboss.weld.environment.servlet.archive.isolation to false:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" 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/web-app_3_0.xsd"> <context-param> <param-name>org.jboss.weld.environment.servlet.archive.isolation</param-name> <param-value>false</param-value> </context-param> </web-app>
Note that there is no such option to disable the implicit bean archive support.