Omnifaces-Exception:CN BeanManager实例在JNDI中不可用 [英] Omnifaces-Exception: CDI BeanManager instance is not available in JNDI

查看:93
本文介绍了Omnifaces-Exception:CN BeanManager实例在JNDI中不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在upserver上部署jsf应用程序时遇到问题.启动tomcat会导致以下异常:

i have problems with deploying my jsf-application on the upserver. starting tomcat results in the following exception:

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.

在我的本地环境中工作正常.我已经检查了所有受影响的文件的状态和值:

in my local enviroment it works fine. i already checked all affected files for presence and values:

WEB-INF
-(空)beans.xml

WEB-INF
-(empty) beans.xml

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

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

META-INF
具有以下内容的context.xml:

META-INF
context.xml with following content:

 <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
omn​​ifaces 2.4
tomcat:安装了cdi的8.0.36,请仔细遵循此处给出的步骤:
http://balusc.omnifaces.org/2013/10/how-to-install-cdi-in-tomcat.html

Enviroment:
java 8
mojarra 2.2.12
omnifaces 2.4
tomcat: 8.0.36 with cdi installed, carefully followed the steps given here:
http://balusc.omnifaces.org/2013/10/how-to-install-cdi-in-tomcat.html

有一个相似的主题,没有帮助.对我来说,解决方案尚不清楚. 在Tomcat 7上部署时出现的Omnifaces例外

there is a similar topic which is not helpful. for me the solution is unclear. Omnifaces exception on deployment on Tomcat 7

我们将不胜感激.

推荐答案

在大多数情况下,使用eclipse及其wtp-server-plugin并依赖清理tomcat工作目录"时,您可能会忘记清理tomcat的工作文件夹在生产环境上部署失败时也是如此.

When you work with eclipse and its wtp-server-plugin and rely on "clean tomcat working directory" the most time, you may forget to cleanup tomcat's work folder also when a deploy fails on production enviroments.

tomcat/webapps/appName
tomcat/webapps/appName.war
tomcat/work

after deletion of
tomcat/webapps/appName
tomcat/webapps/appName.war
tomcat/work

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

i redeployed and the errors went away.

这篇关于Omnifaces-Exception:CN BeanManager实例在JNDI中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆