当前位置: 首页 > 知识库问答 >
问题:

OmniFaces-Exception:CDI BeanManager实例在JNDI中不可用

韦思淼
2023-03-14
14-Jul-2016 07:26:52.661 SEVERE [localhost-startStop-1] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: 
 java.lang.ExceptionInInitializerError
    at org.omnifaces.util.Beans.getManager(Beans.java:88)
    at org.omnifaces.util.Beans.getReference(Beans.java:113)
    at org.omnifaces.application.OmniApplication.<init>(OmniApplication.java:70)
    at org.omnifaces.application.OmniApplicationFactory.createOmniApplication(OmniApplicationFactory.java:89)
    at org.omnifaces.application.OmniApplicationFactory.getApplication(OmniApplicationFactory.java:54)
    at com.sun.faces.application.InjectionApplicationFactory.getApplication(InjectionApplicationFactory.java:93)
    at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:142)
    at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at javax.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:405)
    at javax.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:251)
    at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:543)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:439)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in JNDI.
    at org.omnifaces.config.BeanManager.<init>(BeanManager.java:97)
    at org.omnifaces.config.BeanManager.<clinit>(BeanManager.java:47)
    ... 30 more
Caused by: java.lang.IllegalStateException: javax.naming.NamingException: Cannot create resource instance
    at org.omnifaces.util.JNDI.lookup(JNDI.java:95)
    at org.omnifaces.config.BeanManager.<init>(BeanManager.java:93)
    ... 31 more
Caused by: javax.naming.NamingException: Cannot create resource instance
    at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:96)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:841)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:157)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.omnifaces.util.JNDI.lookup(JNDI.java:90)
    ... 32 more

14-Jul-2016 07:26:52.665 SEVERE [localhost-startStop-1] org.omnifaces.ApplicationListener.checkCDIAvailable 
????????????????????????????????????????????????????????????????????????????????
?                         ??     ?                                             ?
?    ?                  ?????    ? OmniFaces failed to initialize!             ?
?   ????               ??????    ?                                             ?
?   ??????            ???????    ? This OmniFaces version requires CDI, but    ?
?   ???????          ???????     ? none was found on this environment.         ?
?    ???????????????????????     ?                                             ?
?    ???????????????????????     ? OmniFaces 2.x requires a minimum of JSF 2.2.?
?     ?????????????????????      ? Since this JSF version, the JSF managed bean?
?     ?????????????????????      ? facility @ManagedBean is semi-official      ?
?     ??????????????????????     ? deprecated in favour of CDI. JSF 2.2 users  ?
?     ??????????????????????     ? are strongly encouraged to move to CDI.     ?
?     ??????????????????????     ?                                             ?
?    ???????????????????????     ? OmniFaces goes a step further by making CDI ?
?    ????????????????????????    ? a REQUIRED dependency next to JSF 2.2. This ?
?    ????????????????????????    ? not only ensures that your web application  ?
?   ???????????????? ????????    ? represents the state of art, but this also  ?
?   ?????????????????????????    ? makes for us easier to develop OmniFaces,   ?
?   ??????????????????????????   ? without the need for all sorts of hacks in  ?
?   ??????????????????????????   ? in order to get OmniFaces to deploy on      ?
?  ????????????????????????????  ? environments without CDI.                   ?
?  ????????????????????????????  ?                                             ?
?  ????????????????????????????  ? You have 3 options:                         ?
?????????????????????????????????? 1. Downgrade to OmniFaces 1.x.              ?
?????????????????????????????????? 2. Install CDI in this environment.         ?
?????????????????????????????????? 3. Switch to a CDI capable environment.     ?
??????????????????????????????????                                             ?
?????????????????????????????????? For additional instructions, check          ?
?????????????????????????????????? http://omnifaces.org/cdi                    ?
??????????????????????????????????                                             ?
????????????????????????????????????????????????????????????????????????????????
14-Jul-2016 07:26:52.682 INFO [localhost-startStop-1] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra 2.2.12 ( 20150720-0848 https://svn.java.net/svn/mojarra~svn/tags/2.2.12@14885) for context '/protano'
14-Jul-2016 07:26:52.840 INFO [localhost-startStop-1] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.
14-Jul-2016 07:26:52.872 SEVERE [localhost-startStop-1] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: 
 java.lang.NoClassDefFoundError: Could not initialize class org.omnifaces.config.BeanManager
    at org.omnifaces.util.Beans.getManager(Beans.java:88)
    at org.omnifaces.util.Beans.getReference(Beans.java:113)
    at org.omnifaces.application.OmniApplication.<init>(OmniApplication.java:70)
    at org.omnifaces.application.OmniApplicationFactory.createOmniApplication(OmniApplicationFactory.java:89)
    at org.omnifaces.application.OmniApplicationFactory.getApplication(OmniApplicationFactory.java:54)
    at com.sun.faces.application.InjectionApplicationFactory.getApplication(InjectionApplicationFactory.java:93)
    at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:142)
    at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at javax.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:405)
    at javax.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:251)
    at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:543)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:439)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4840)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

14-Jul-2016 07:26:52.889 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start.

WEB-INF/lib
-cdi-api-1.2.jar
-weld-servlet-2.2.9.final.jar

包含以下内容的META-INF
context.xml:

 <Context>
   <Resource name="BeanManager" 
      auth="Container"
      type="javax.enterprise.inject.spi.BeanManager"
      factory="org.jboss.weld.resources.ManagerObjectFactory"/>
 </Context>

环境:
java 8
mojarra 2.2.12
omnifaces 2.4
Tomcat:8.0.36安装cdi后,请仔细按照以下步骤操作:
http://balusc.omnifaces.org/2013/10/how-to-install-cdi-in-tomcat.html

如有任何其他帮助/建议,将不胜感激。

共有1个答案

束新
2023-03-14

当您使用eclipse及其wtp-server-plugin并且大部分时间依赖于“清理tomcat工作目录”时,当生产环境中的部署失败时,您可能也会忘记清理tomcat的工作文件夹。

删除
tomcat/webapps/appname
tomcat/webapps/appname.war
tomcat/work

我重新部署了,错误消失了。

 类似资料:
  • OmniFaces 是一个 JSF 2 的工具库,其目的是为了让 JSF 应用开发更加简单。 如果你厌倦了重塑JSFUtil或FacesUtil实用程序类,为每个JSF web应用程序定制组件,使用 taghandlers 等来解决JSF的缺点的话,OmniFaces可能是你要找的东西!

  • 在我的世界里,有两只耳朵。第一个EAR查找打包在第二个EAR中的ejb。我的问题是,既然两个耳朵在同一个WAS中,我们还需要提供属性或者服务器会自动定位EJB吗?

  • 这里给出的常量应该在XHTML页面上检索,如下所示。 这适用于在GlassFish4.0上运行JSF托管bean的企业应用程序。 但是,在使用Spring(4.0GA)、JSF 2.2.6、PrimeFaces 5.0 final、PrimeFaces Extensions 2.0.0 final运行在Tomcat 8.0.3.0上的项目中,同样的事情也不起作用。 这应该与Spring无关。 给定

  • 这里尝试将应用程序从WAS 8迁移到Liberty。在运行应用程序时遇到关于JNDI查找的错误, 错误 CWNEN1001E:无法实例化java:comp/env/hronlinefsdev2 JNDI名称引用的对象。如果引用名称映射到执行JNDI查找的应用程序的部署描述符绑定中的JNDI名称,请确保部署描述符绑定中的JNDI名称映射是正确的。如果JNDI名称映射正确,请确保可以使用相对于默认初始

  • 我需要一些帮助在使用一个OmniFaces功能。 我有以下web.xml配置 然而,当异常发生时,用户只会被重定向到默认的500错误页面。 只有当我将错误页移出WEB-INF文件夹/WEB-INF/pages/errors/pagenotfound.xhtml-->/pages/errors/pagenotfound.xhtml时,重定向才会起作用 但这意味着现在可以直接访问错误页。但在Omnif

  • 我做了这方面的所有工作:如何连接tomcat 7和mysql<br>但它仍然无法工作……为什么?我错过了什么? OS:Win7<br>Eclipse:J2EE Mars<br>Tomcat:Tomcat 8.0<br>java:1.8.0_73<br>数据库名称:测试<br>用户名:root<br>密码:123 (在TOMCAT_HOME/conf中)< br >(也在localhost-conf