For GateIn users using Tomcat which does as being a barebones JSP/Servlet container. You’d need to install a CDI implementation which does support working under Tomcat.
In this documentation, we will guide to install Weld - a CDI reference implementation, as Weld documentation is pretty clear and easy to install under Tomcat.
Perform the following steps:
This is an uber JAR of Weld itself, contains both API and Impl. At the time of writing, weld-servlet 1.1.8.Final version is being used.
2. Create /META-INF/context.xml file in webapp's web content with following content (or, if you already have one, add just the <Resource> to it):
This will register Weld's BeanManager factory in Tomcat's JNDI.
The listener entry basically enables Weld in webapp. The resource entry basically tells webapp to use the BeanManager as available in JNDI.
As you know, GateIn has provided two Portlet CDI scope annotations @PortletLifecycleScoped and @PortletRedisplayScoped which support the complex Portlet Lifecycle within CDI. BUT if you want to have them work under Tomcat, you need to add the following listener org.gatein.cdi.contexts.listeners.TomcatCDIServletListener to webapp's /WEB-INF/web.xml