gpt4 book ai didi

tomcat7 - 在 Tomcat 7 上部署时出现 Omnifaces 异常

转载 作者:行者123 更新时间:2023-12-05 07:54:03 25 4
gpt4 key购买 nike

我正在尝试将 Omnifaces 2.1 添加到 Web 应用程序以使用 FullAjaxExceptionHandler 以及 Omnifaces 2.1 中可能的其他功能。

我已经阅读并关注了 BallusC 的以下帖子,但仍然卡住了: How to install and use CDI on Tomcat?

尝试安装 Weld 2.2.9.Final 并按上述配置。我正在使用以下内容:

JSF 2.2、EL 2.2、Servlet 3、Java 7

web.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="{name}" version="3.0">

启动时我仍然收到以下异常:

卡特琳娜日志:

INFO: Starting service Catalina
Aug 09, 2015 8:57:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.56
Aug 09, 2015 8:57:18 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\xampp\tomcat\conf\Catalina\localhost\MITrace.xml
Aug 09, 2015 8:57:24 AM org.richfaces.webapp.ResourceServletContainerInitializer registerServlet
INFO: Auto-registered servlet ResourceServlet with mapping '/org.richfaces.resources/*'
Aug 09, 2015 8:57:24 AM org.omnifaces.ApplicationInitializer logOmniFacesVersion
INFO: Using OmniFaces version 2.1
Aug 09, 2015 8:57:26 AM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.2.6 ( 20140304-1537 https://svn.java.net/svn/mojarra~svn/tags/2.2.6@12949) for context '/MITrace'
Aug 09, 2015 8:57:27 AM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
Aug 09, 2015 8:57:27 AM com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment:
java.lang.NoClassDefFoundError: Could not initialize class org.omnifaces.config.BeanManager
at org.omnifaces.application.OmniApplication.<init>(OmniApplication.java:69)
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:144)
at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:379)
at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:721)
at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:553)
at javax.faces.FactoryFinder.access$500(FactoryFinder.java:140)
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1120)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
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:435)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1861)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

本地主机.log:

Aug 09, 2015 10:28:23 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Aug 09, 2015 10:28:25 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Aug 09, 2015 10:28:27 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: 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:4994)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1861)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
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:99)
at org.omnifaces.config.BeanManager.<clinit>(BeanManager.java:49)
... 15 more
Caused by: java.lang.IllegalStateException: javax.naming.NamingException: Cannot create resource instance
at org.omnifaces.util.JNDI.lookup(JNDI.java:92)
at org.omnifaces.config.BeanManager.<init>(BeanManager.java:95)
... 16 more
Caused by: javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:115)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.omnifaces.util.JNDI.lookup(JNDI.java:88)
... 17 more

该 jar 确实存在并且已添加到应用程序中。

还有什么可能导致此错误?

最佳答案

好的问题现在已经解决了。我可以确认 Apache Tomcat/7.0.56 的以下内容:

  • /META-INF/context.xml 不是必需的,但仍然需要资源条目。为了解决这个问题,我在以下现有位置添加了资源条目:tomcat\conf\Catalina\localhost{resource-file-name}.xml

之后没有出现错误。

  • 不需要在web.xml中注册相关监听器
  • 没有相关<resource-env-ref>在 web.xml 中是必需的
  • 需要/WEB-INF/beans.xml(空)

此处涵盖了以上大部分内容:http://balusc.blogspot.com.au/2013/10/how-to-install-cdi-in-tomcat.html

我想对此提供更新,因为有些人可能会发现 tomcat 上的资源加载部分很有帮助。

再次感谢 BallusC。我对类似的帖子投了赞成票,因为与之相关的建议帮助我解决了这个问题。

关于tomcat7 - 在 Tomcat 7 上部署时出现 Omnifaces 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31899406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com