javax.faces.FacesException:无法找到CDI BeanManager

时间:2019-11-23 14:18:05

标签: java tomcat jsf servlets

因此,我是开发Java EE Web应用程序的一个完整的初学者,在启动一个简单项目时遇到了一些问题。

每当我尝试运行此代码时:

<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
    <title>Hello World JSF 2.3</title>
</h:head>
<h:body>

    <h:form>
        <h:outputLabel for="input" value="Who do you want to greet?"/>
        <h:inputText id="input" value="#{helloWorldBacking.name}"/>
        <h:commandButton value="Submit"
                         action="#{helloWorldBacking.greetPerson}">
        </h:commandButton>
        <br/>
        <h:outputText value="#{helloWorldBacking.greet}"/>
    </h:form>

</h:body>
</html>

我在屏幕上看到了这个消息:“原始服务器找不到目标资源的当前表示,或者不愿意透露该资源的存在。”

运行该文件后,我收到这些错误的垃圾邮件:

    SEVERE: Critical error during deployment: 
javax.faces.FacesException: Unable to find CDI BeanManager
	at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:312)
	at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:242)
	at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:484)
	at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1404)
	at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:526)
	at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4683)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)

Nov 23, 2019 4:05:59 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: 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)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4683)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: javax.faces.FacesException: Unable to find CDI BeanManager
	at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:312)
	at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:242)
	at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:484)
	at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1404)
	at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:526)
	at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256)
	... 30 more

我正在使用tomcat 9.0和JSF 2.3.0

有人可以帮助我解决此问题吗? 谢谢!

0 个答案:

没有答案