Error starting JSF application in Apache - CDI Beanmanager instance is not available in JNDI

Asked

Viewed 92 times

0

I have a JSF + Primefaces application that runs smoothly in the development environment. But when it comes to deploying . War in Tomcat, in production, I can’t. The error in the logs is:

java.lang.IllegalStateException: CDI BeanManager instance is not available in JNDI.

References to omnifaces in the project are:

import org.omnifaces.util.Faces; (in some Beans)

<resource-handler>org.omnifaces.resourcehandler.CombinedResourceHandler</resource-handler> (faces-config)

Can someone help me?

Version Tomcat 8.8.42. OS: Ubuntu 16.04

Error stack:

SEVERE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.omnifaces.ApplicationListener]
    java.lang.ExceptionInInitializerError
        at org.omnifaces.ApplicationListener.checkCDIAvailable(ApplicationListener.java:63)
        at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:55)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1414)
        at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1378)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1613)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
        at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1170)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1392)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1396)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1364)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in JNDI.
        at org.omnifaces.config.BeanManager.<init>(BeanManager.java:106)
        at org.omnifaces.config.BeanManager.<clinit>(BeanManager.java:49)
        ... 15 more
  • 1

    You probably have conflicting/duplicate libs in the server classpath, I suggest validating the constant libs in the classpath as well as those sent with your application

  • Thanks for the tip. But you can explain better how I do to locate possible conflicts hi duplicities?

1 answer

2

You probably have conflict between your project libs and server libs, this may happen for some reasons:

  1. Incompatible libs (different libs where versions "don’t talk to each other")
  2. Same lib in different versions (several versions of JSF for example)
  3. Libs packaged in the project but already in some shared lib server
  4. ...

This work of checking libs is very boring, I recommend you perform the following procedures:

  1. Check the libs being packaged in your WAR / EAR - usually packaged in the WEB-INF/lib of the application
  2. Check the constant libs in the server classpath - usually you can view the constant folders in the classpath by running echo $CLASSPATH
  3. Search for conflicting libs (different versions, libs that should be provided by the server but are being packaged in WAR...)

Good luck in the endeavor :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.