1

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Hicham
  • 170
  • 2
  • 16
  • 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 Nov 05 '15 at 16:25

1 Answers1

3

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.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • when I moved both PrimeFaces and OmniFaces to /WEB-INF/ I get even more exceptions. but with PrimeFaces on domain1/lib and OmniFaces on /WEB-INF/ my web app started but get a lot of warnings like : WEB9052: Unable to load class org.omnifaces.component.script.OnloadScript, reason: java.lang.ClassNotFoundException: org.omnifaces.component.script.OnloadScript. even if I didn't use yet any OmniFaces component! – Hicham Nov 05 '15 at 16:40
  • GlassFish may be still dirty. Cleanup its work folder and libraries. Remember to never touch the server's libs this way. Never put webapp-specific libraries in server itself or even the JRE. In case you're unsure, trash and re-unzip GlassFish. Always install web libraries such as OmniFaces and PrimeFaces in `/WEB-INF/lib`. – BalusC Nov 05 '15 at 16:41
  • I moved OmniFaces from /WEB-INF to /WEB-INF/lib and it works like a charme. (even if I still get PrimeFaces and other libraries in the GlassFish domain 1 lib) Many thanks BalusC. U r always there to support us. – Hicham Nov 05 '15 at 16:43
  • You're welcome. Remember: putting web fragment libraries there outside webapp is wrong. Put back PrimeFaces too. – BalusC Nov 05 '15 at 16:46
  • 1
    The size of my war file will grow and deploying it frow tne network will take too much time. It is usual ? – Hicham Nov 05 '15 at 16:54
  • We're at 2015 not 1995. It'll cost one second extra, not a minute or ten. Nonetheless, web libraries belong in WAR. Period. That's also what the "W" in WAR stands for. – BalusC Nov 05 '15 at 16:56