@Eager 不可用。无法从 CDI bean 管理器获取 EagerBeansRepository

@Eager is unavailable. The EagerBeansRepository could not be obtained from CDI bean manager

这是我第一次使用 omnifaces。 我的应用程序在没有它的情况下运行良好,但当我尝试它时,出现以下异常。

java.lang.NullPointerException
    at org.omnifaces.cdi.eager.EagerBeansPhaseListener.afterPhase(EagerBeansPhaseListener.java:50)
    at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.arp.DefaultAsyncExecutor.execute(DefaultAsyncExecutor.java:159)
    at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:145)
    at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:102)
    at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
    at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
    at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
    at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:745)

我在 Netbeans 中创建了一个新的空 Web 应用程序,运行 它在 Glassfish 3.1.2.2 下 使用 : OmniFaces 版本 2.1 莫哈拉 2.2.12 PrimeFaces 5.3 PrimeFaces 扩展 3.2。 每次我 运行 应用程序在 glass fish 启动期间出现以下警告时仍然会出现相同的错误:

@Eager is unavailable. The EagerBeansRepository could not be obtained from CDI bean manager.

有什么帮助吗?

当我从 glassfish domain1/lib 目录中删除 omnifaces-2.1.jar 时,一切正常。

When I remove omnifaces-2.1.jar from glassfish domain1/lib directory, everything works fine.

网络图书馆不属于那里。 Web 库属于 WAR 的 /WEB-INF/lib。当错放在 /WEB-INF/lib 之外时,webapp 将无法在网络库中找到 JSF/CDI 注释的 classes 并抛出与此相关的异常。

将 OmniFaces JAR 文件从 domain1/lib 放回 /WEB-INF/lib。然后 JSF 将能够找到 OmniFaces 中捆绑的 @FacesComponent 注释的 classes,而 CDI 将能够找到 OmniFaces 中捆绑的 @XxxScoped classes,例如 EagerBeansRepository class.

另请参阅 OmniFaces homepage 的“安装”部分:

Installation

It is a matter of dropping the OmniFaces 2.1 JAR file in /WEB-INF/lib.

...

OmniFaces is designed as a WAR library (web fragment library) and therefore can't be placed elsewhere in the webapp's runtime classpath outside WAR's own /WEB-INF/lib, such as EAR's /lib or even server's or JRE's own /lib. When OmniFaces JAR file is misplaced this way, then the webapp will be unable to find OmniFaces-bundled JSF/CDI annotated classes and throw exceptions related to this during deploy or runtime. To solve it, put back OmniFaces in WAR's /WEB-INF/lib.