0

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"}}
Setu
  • 149
  • 1
  • 10
  • 1
    Please remove cdi-api-2.0.jar jsr311-api-1.1.1.jar weld-se-shaded-3.1.3.Final.jar and retry. All of these are already provided by WildFly as being a normal Java EE server. These libraries are only necessary when you don't target a normal Java EE server such as Tomcat or Jetty. Right now you basically end up with duplicate different versioned libraries in the runtime classpath which are conflicting each other. This will always end up in "weird" runtime behavior. – BalusC Dec 24 '19 at 09:41
  • Hi @BalusC, I tried without these jars also. It ends up with same error. – Setu Dec 24 '19 at 10:49
  • Please include the root cause of the stack trace in your question. – BalusC Dec 24 '19 at 10:58
  • Your question has become really confusing. The stack trace which you pasted is the one from when you incorrectly manually installed CDI as per *"Now, I am trying to add CDI Bean manager in my EAR. But I am continuously getting following exception"* . Please rollback everything to the condition which caused *"Firstly it was giving me class clash exception for ApplicationFactory class"* and then post the root cause of that exception. In other words, please undo all the attempted fixes because they are most likely all wrong. – BalusC Dec 24 '19 at 11:19
  • Ok. I got the concern. Let me try to get it. I am trying to regenerate but it is continuously giving me the same error. (CDI Bean manager only...) – Setu Dec 24 '19 at 11:45
  • Maybe do a clean build... Fully clean... – Kukeltje Dec 24 '19 at 11:56
  • Ok. I came to know that weld is disabled in our EAR. And on enabling the same, we are getting another error. Caused by: java.lang.reflect.MalformedParameterizedTypeExceptionCaused by: java.lang.reflect.MalformedParameterizedTypeException – Setu Dec 24 '19 at 12:47

0 Answers0