如何使CDI BeanManager实例在wildfly 11.0中可用?

时间:2019-12-24 08:13:11

标签: jsf wildfly cdi omnifaces

我正在使用 JSF 2.3和richfaces 4.5.17 。我想在战争项目中使用Omnifaces。首先,它给了我 ApplicationFactory 类的类冲突异常。通过谷歌搜索,了解了 CDI bean管理器

现在,我正在尝试在EAR中添加CDI Bean管理器。但是我不断收到以下异常:

  

{“ WFLYCTL0062:复合操作失败并被回滚。步骤   失败:“ => {”操作步骤2“ => {” WFLYCTL0080:失败   服务” =>   {“ jboss.undertow.deployment.default-server.default-host./my-war” =>   “ java.lang.RuntimeException:java.lang.IllegalStateException:CDI   BeanManager实例在此环境中不可用。       引起原因:java.lang.RuntimeException:java.lang.IllegalStateException:CDI BeanManager实例不是   在这种环境下可用。       原因:java.lang.IllegalStateException:CDI BeanManager实例在此环境中不可用。       由以下原因引起:java.lang.NullPointerException“}}}}

以下是我的构建结构:

my-ear.ear
    -- my-ejb.jar
    -- my-entity.jar
    -- my-war.war

我已经将空的 beans.xml 文件放在 my-war / WEB-INF 中。

我还在 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

我在网上了解到wildfly具有内部CDI,无需单独安装。我提到了这些链接:

CDI Reference omnifaces-exception-cdi-beanmanager-instance-is-not-available-in-jndi

编辑

我使用Omnifaces jar的根本原因是使用byte []获得了图像视图的弹出功能。我想要的另一个功能是在XHTML中包含JSP页面。这些都由Omnifaces共同提供。我在这里遇到的错误的完整日志是:

????????????????????????????????????????????????????????????????????????????????
?                         ??     ?                                             ?
?    ?                  ?????    ? 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"}}

0 个答案:

没有答案