Good morning, everyone. I'm doing the book project "algaworks-ebook-java-ee-7-with-jsf-primefaces-and-cdi-2a-edicao-20150228" and I'm having trouble adding omnifaces .
When I go up tomcat, I get the following error:
...
INFO: WELD-ENV-001100: Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
mai 26, 2016 10:13:07 AM org.omnifaces.ApplicationInitializer logOmniFacesVersion
INFORMAÇÕES: Using OmniFaces version 2.3
mai 26, 2016 10:13:07 AM org.jboss.weld.environment.servlet.Listener contextInitialized
INFO: WELD-ENV-001006: org.jboss.weld.environment.servlet.EnhancedListener used for ServletContext notifications
mai 26, 2016 10:13:07 AM org.omnifaces.ApplicationListener checkCDIAvailable
GRAVE:
????????????????????????????????????????????????????????????????????????????????
? ?? ? ?
? ? ????? ? OmniFaces failed to initialize! ?
? ???? ?????? ? ?
? ?????? ??????? ? This OmniFaces version requires CDI, but ?
? ??????? ??????? ? none was found on this environment. ?
? ??????????????????????? ? ?
? ??????????????????????? ? OmniFaces 2.x requires a minimum of JSF 2.2.?
? ????????????????????? ? Since this JSF version, the JSF managed bean?
? ????????????????????? ? facility @ManagedBean is semi-official ?
? ?????????????????????? ? deprecated in favour of CDI. JSF 2.2 users ?
? ?????????????????????? ? are strongly encouraged to move to CDI. ?
? ?????????????????????? ? ?
? ??????????????????????? ? OmniFaces goes a step further by making CDI ?
? ???????????????????????? ? a REQUIRED dependency next to JSF 2.2. This ?
? ???????????????????????? ? not only ensures that your web application ?
? ???????????????? ???????? ? represents the state of art, but this also ?
? ????????????????????????? ? makes for us easier to develop OmniFaces, ?
? ?????????????????????????? ? without the need for all sorts of hacks in ?
? ?????????????????????????? ? in order to get OmniFaces to deploy on ?
? ???????????????????????????? ? environments without CDI. ?
? ???????????????????????????? ? ?
? ???????????????????????????? ? You have 3 options: ?
?????????????????????????????????? 1. Downgrade to OmniFaces 1.x. ?
?????????????????????????????????? 2. Install CDI in this environment. ?
?????????????????????????????????? 3. Switch to a CDI capable environment. ?
?????????????????????????????????? ?
?????????????????????????????????? For additional instructions, check ?
?????????????????????????????????? http://omnifaces.org/cdi ?
?????????????????????????????????? ?
????????????????????????????????????????????????????????????????????????????????
...
Remembering that:
- Environment (Tomcat 8, Java 8)
- I already have Weld CDI configured and working
Pom:
<!-- Weld (implementação do CDI) -->
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<version>2.3.4.Final</version>
<scope>compile</scope>
</dependency>
<!-- OmniFaces (utilitarios para JSF) -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
context.xml in the src / main / webapp / META-INF directory:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Manager pathname="" />
<Resource name="BeanManager" auth="Container"
type="javax.enterprise.inject.spi.BeanManager" factory="org.jboss.weld.resources.ManagerObjectFactory" />
</Context>
web.xml
<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>
beans.xml - In the src / main / resources / META-INF directory
<?xml version="1.0" encoding="UTF-8"?>
<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"
version="1.1" bean-discovery-mode="all">
<interceptors>
<class>
com.algaworks.util.TransactionInterceptor
</class>
</interceptors>
</beans>