[Java] How to deal with Unable to find CDI Bean Manager.

2 minute read

  • 環境
    • CentOS Linux release 7.8.2003 (Core)
    • Eclipse IDE for Enterprise Java Developers. Version: 2020-03 (4.15.0)
    • openjdk version “11.0.7”
    • Payara Server 5.194

事象 : JSFのプロジェクトをPayaraを起動したらエラーログが表示された

エラーログのメッセージ


cannot Deploy tryJsf
deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager. Please see server.log for more details.]

server.log


[2020-07-20T21:13:22.486+0900] [Payara 5.194] [重大] [] [javax.enterprise.resource.webcontainer.jsf.config] [tid: _ThreadID=49 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1595247202486] [levelValue: 1000] [[
  Critical error during deployment: 
javax.faces.FacesException: Unable to find CDI BeanManager
    at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:288)
    at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:218)
    at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:467)
...省略...
]]

[2020-07-20T21:13:22.490+0900] [Payara 5.194] [重大] [AS-WEB-CORE-00174] [javax.enterprise.web.core] [tid: _ThreadID=49 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1595247202490] [levelValue: 1000] [[
  Startup of context /tryJsf failed due to previous errors]]

[2020-07-20T21:13:22.492+0900] [Payara 5.194] [重大] [AS-WEB-CORE-00175] [javax.enterprise.web.core] [tid: _ThreadID=49 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1595247202492] [levelValue: 1000] [[
  Exception during cleanup after start failed
org.apache.catalina.LifecycleException: Manager has not yet been started
    at org.apache.catalina.session.StandardManager.stop(StandardManager.java:868)
    at org.apache.catalina.core.StandardContext.stop(StandardContext.java:5940)
    at com.sun.enterprise.web.WebModule.stop(WebModule.java:648)
...省略...
]]

[2020-07-20T21:13:22.493+0900] [Payara 5.194] [重大] [AS-WEB-CORE-00108] [javax.enterprise.web.core] [tid: _ThreadID=49 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1595247202493] [levelValue: 1000] [[
  ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5760)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:619)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:956)
...省略...
Caused by: java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:283)
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5165)
...省略...
Caused by: javax.faces.FacesException: Unable to find CDI BeanManager
    at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:288)
    at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:218)
...省略...
]]

[2020-07-20T21:13:22.495+0900] [Payara 5.194] [警告] [] [javax.enterprise.web] [tid: _ThreadID=49 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1595247202495] [levelValue: 900] [[
  java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:960)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:939)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
...省略...
]]

[2020-07-20T21:13:22.504+0900] [Payara 5.194] [重大] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=49 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1595247202504] [levelValue: 1000] [[
  Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:136)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:123)
...省略...
]]

[2020-07-20T21:13:22.505+0900] [Payara 5.194] [重大] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=49 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1595247202505] [levelValue: 1000] [[
  Exception during lifecycle processingjava.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:136)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:123)
...abridgement...
]]

Cause: JSF library is not specified

Although I specified “2.3” in [JavaServer Faces] for the project, I did not specify any library…

Reference: [New graduate SE Java EE Challenge 2 (JSF Edition) Iterative Co., Ltd.](https://www.iterative.co.jp/blog/javaee2-%EF%BD%8A%EF%BD%93%EF%BD%86/)

pom.xml

 did nothing in the initial state
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/ /maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ponsuke</groupId>
  <artifactId>tryJsf</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
</project>

Supported: Put JSF library in pom.xml

  1. Copy the definition of any version from Maven Repository: org.glassfish »javax.faces
  2. Append to pom.xml
  3. Clean Payara> Clean Project> Run As> Run Os Server in Project

pom.xml


...abridgement...
  <dependencies>
    <dependency>
      <groupId>org.glassfish</groupId>
      <artifactId>javax.faces</artifactId>
      <version>2.3.9</version>
    </dependency>
  </dependencies>
</project>