添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
逃跑的椰子  ·  确定SQL ...·  2 年前    · 
大力的砖头  ·  cypher - How get the ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

javax.faces.FacesException: Unable to find CDI BeanManager at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:312) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:242) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:484) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1404) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:526) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256) ~[javax.faces-2.3.0.jar:2.3.0] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4725) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-8.5.5.jar:8.5.5] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]

2017-05-15 11:12:44.071 ERROR 9936 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener

java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:315) ~[javax.faces-2.3.0.jar:2.3.0] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4725) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-8.5.5.jar:8.5.5] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111] Caused by: javax.faces.FacesException: Unable to find CDI BeanManager at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:312) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:242) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:484) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1404) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:526) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256) ~[javax.faces-2.3.0.jar:2.3.0]

I also updated the version in my faces-config.xml to 2.3:

<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
          version="2.3">
<application>
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    <el-resolver>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerELResolver</el-resolver>
</application>
<factory>
    <exception-handler-factory>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory</exception-handler-factory>
</factory>
                You question title 'How to update...' is way to broad for the problem. Please improve the title... And a full stacktrace most likely contains the reason... I only see Spring errors here, nothing JSF related
– Kukeltje
                May 15, 2017 at 9:16
                I guess in faces-config.xml the xsi:schemaLocation should also be updated to 2.3: xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd
– Lars Gendner
                Nov 17, 2017 at 14:58

Old question, but for people still facing this problem: To avoid the "Unable to find CDI BeanManager" error, it's important that your faces-config.xml version is not 2.3 and your web.xml version is not 4.0!

The Mojarra implementation ELUtils class contains the following nice bit of code:

if (getFacesConfigXmlVersion(facesContext).equals("2.3") || getWebXmlVersion(facesContext).equals("4.0")) {
                throw new FacesException("Unable to find CDI BeanManager");

When using lower versions, it skips this check, and works with Spring DI instead of CDI.

I can't understand why this nice little piece of code is inside GlassFish's JSF implementation! The jar is versioned 2.3 yet it throws an exception if used under Servlet 4.0? Or I wrongly understood this? – Ali Bassam Dec 10, 2017 at 12:02 IF you are using @ManagedBean annotations this is needed. If you are using @Named (as you should) you don't get this error – Kukeltje Jan 9, 2020 at 22:32 <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet</artifactId> <version>2.2.9.Final</version> </dependency>
  • create beans.xml in WEB-INF
    <?xml version="1.0" encoding="UTF-8"?>
    <beans
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:weld="http://jboss.org/schema/weld/beans"
        xsi:schemaLocation="
        http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd
        http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
      <weld:scan>
        <weld:exclude name="org.springframework.data.jpa.repository.cdi.**" />
        <weld:exclude name="com.example.beans.**" />
      </weld:scan>
    </beans>
    

    Well, my answear may appears unrelated to this question, but it is... I experienced exactly this exception, and it was not the first time. I have one enviroment in production and another, for development. They are identical, as much as possible. My environment is glassfish 4.1.2, updated to use mojarra 2.3 (I've swapped the glassfish4/glassfish/modules/javax.faces.jar file). I have some secure certificates in one .jks file, and this information is very important, one jvm setting called "-Djavax.net.ssl.trustStorePassword", with default value "changeit". For some strange reason this setting disappeared in one deploy. I don't know why, but it happened. My conclusion is that this missing setting had thrown one exception BEFORE the exception "javax.faces.FacesException: Unable to find CDI BeanManager" and I could not diagnose it. That was the only differece between this two environments. So, if your application is throwing this exception and it uses some .jks file, just verify that this setting is not missing in your jvm settings.

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •