Skip to content

Instantly share code, notes, and snippets.

@wesleyegberto
Created April 8, 2017 04:52
Show Gist options
  • Save wesleyegberto/288dc146463cd479fe805f0b5a9f3dd1 to your computer and use it in GitHub Desktop.
Save wesleyegberto/288dc146463cd479fe805f0b5a9f3dd1 to your computer and use it in GitHub Desktop.
CDI 1.2/2.0 on Tomcat
<?xml version="1.0"?>
<!-- WEB-INF/beans.xml -->
<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"/>
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- webapp/META-INF/Context.xml -->
<Manager pathname=""/>
<Resource name="BeanManager"
auth="Container"
type="javax.enterprise.inject.spi.BeanManager"
factory="org.jboss.weld.resources.ManagerObjectFactory"/>
</Context>
<!-- CDI 2.0 -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0-PFD2</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<version>3.0.0.CR2</version>
</dependency>
<web-app 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/web-app_3_1.xsd"
version="3.1">
<!-- Comment the listener and resource-env-ref on Tomcat 8.5.4 -->
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>
javax.enterprise.inject.spi.BeanManager
</resource-env-ref-type>
</resource-env-ref>
</web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment