I am using JSF 2.3 and richfaces 4.5.17. I want to use Omnifaces in my war project. Firstly it was giving me class clash exception for ApplicationFactory class. On googling, came to know about CDI bean manager.
Now, I am trying to add CDI Bean manager in my EAR. But I am continuously getting following exception:
{"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./my-war" => "java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment. Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment. Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment. Caused by: java.lang.NullPointerException"}}}}
Following is my Build structure:
my-ear.ear
-- my-ejb.jar
-- my-entity.jar
-- my-war.war
I have put empty beans.xml file in my-war/WEB-INF.
I also have added following dependencies in my-war/WEB-INF/lib:
omnifaces-3.4.1.jar
cdi-api-2.0.jar
jsr311-api-1.1.1.jar
weld-se-shaded-3.1.3.Final.jar
I came to know online that wildfly has its internal CDI and no need to install separate. I referred these links:
CDI Reference omnifaces-exception-cdi-beanmanager-instance-is-not-available-in-jndi
EDIT
Root cause of my using Omnifaces jar is to get popup functionality for image view using byte[]. And another functionality I want is to include JSP page in XHTML. These both together provided by Omnifaces. Full logs of the error I am getting here is:
????????????????????????????????????????????????????????????????????????????????
? ?? ? ?
? ? ????? ? OmniFaces failed to initialize! ?
? ???? ?????? ? ?
? ?????? ??????? ? This OmniFaces version requires CDI, ?
? ??????? ??????? ? but none was found on this environment. ?
? ??????????????????????? ? ?
? ??????????????????????? ? OmniFaces 3.x requires a minimum of JSF 2.3.?
? ????????????????????? ? Since this JSF version, the JSF managed bean?
? ????????????????????? ? facility @ManagedBean is DEPRECATED in ?
? ?????????????????????? ? in favour of CDI and CDI has become a ?
? ?????????????????????? ? REQUIRED dependency for JSF 2.3. ?
? ?????????????????????? ? ?
? ??????????????????????? ? ?
? ???????????????????????? ? ?
? ???????????????????????? ? ?
? ???????????????? ???????? ? ?
? ????????????????????????? ? ?
? ?????????????????????????? ? ?
? ?????????????????????????? ? ?
? ???????????????????????????? ? ?
? ???????????????????????????? ? ?
? ???????????????????????????? ? 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 ?
?????????????????????????????????? ?
????????????????????????????????????????????????????????????????????????????????
[::::::::::] 16:31:56,259 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 92) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./my-war: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./my-war: java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:84) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_151]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_151]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_151]
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:241)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:99) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
... 6 more
Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
at org.omnifaces.ApplicationListener.checkCDIImplAvailable(ApplicationListener.java:199)
at org.omnifaces.ApplicationListener.checkCDI11Available(ApplicationListener.java:116)
at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:77)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:205)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:174)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508) [wildfly-undertow-11.0.0.Final.jar:11.0.0.Final]
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:239)
... 8 more
Caused by: java.lang.NullPointerException
at org.omnifaces.ApplicationListener.checkCDIImplAvailable(ApplicationListener.java:196)
... 22 more
[::::::::::] 16:31:56,272 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 4) WFLYCTL0013: Operation ("deploy") failed - address: ({"deployment" => "my-ear-ear-8.1.391.ear"}) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./my-war" => "java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
Caused by: java.lang.NullPointerException"}}
[::::::::::] 16:31:56,276 ERROR [org.jboss.as.server] (management-handler-thread - 4) WFLYSRV0021: Deploy of deployment "my-ear-ear-8.1.391.ear" was rolled back with the following failure message:
{"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./my-war" => "java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in this environment.
Caused by: java.lang.NullPointerException"}}