1
votes

This is my first usage of omnifaces. My app works well without it but when I tried it I get the following exception.

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)

I have created a new empty web app in Netbeans, run it under Glassfish 3.1.2.2 using : OmniFaces version 2.1 Mojarra 2.2.12 PrimeFaces 5.3 PrimeFaces Extensions 3.2. and still get the same error each time I run the app with the following warning during glass fish startup:

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

Any help please?

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

1
with 1.8.3 I get the following exception :Grave: Exception while loading the app Grave: Exception while loading the app : Exception List with 1 exceptions: Exception 0 : java.lang.NullPointerException at org.omnifaces.util.Beans.getReference(Beans.java:78) at org.omnifaces.util.Beans.getReference(Beans.java:66)....Hicham

1 Answers

3
votes

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

Web libraries doesn't belong there. Web libraries belong in /WEB-INF/lib of the WAR. When misplaced outside /WEB-INF/lib, then the webapp won't be able to find JSF/CDI annotated classes in the web library and throw exceptions related to this.

Put back OmniFaces JAR file from domain1/lib into /WEB-INF/lib. Then JSF will be able to find @FacesComponent annotated classes bundled in OmniFaces and CDI will be able to find @XxxScoped classes bundled in OmniFaces, such as the EagerBeansRepository class.

See also "Installation" section of 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.