问题描述
我正在使用MAVEN
,并且已经从以下位置更改了我的pom.xml
依赖项:
I'm using MAVEN
and already changed my pom.xml
dependencies from:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.13</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
收件人:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.3.0</version>
</dependency>
但是现在我得到一个构建错误:
but now I get a build error:
2017-05-15 11:12:44.071错误9936 --- [ost-startStop-1] oaccC [Tomcat].[localhost].[/]:将上下文初始化事件发送到com类的侦听器实例的异常. sun.faces.config.ConfigureListener
2017-05-15 11:12:44.071 ERROR 9936 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.RuntimeException:javax.faces.FacesException:无法找到CDI BeanManager 在com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:315)〜[javax.faces-2.3.0.jar:2.3.0] 在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4725)上[tomcat-embed-core-8.5.5.jar:8.5.5] 在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189)上[tomcat-embed-core-8.5.5.jar:8.5.5] 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)上[tomcat-embed-core-8.5.5.jar:8.5.5] 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1403)[tomcat-embed-core-8.5.5.jar:8.5.5] 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1393)[tomcat-embed-core-8.5.5.jar:8.5.5] 在java.util.concurrent.FutureTask.run(FutureTask.java:266)[na:1.8.0_111] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_111] 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_111] 在java.lang.Thread.run(Thread.java:745)[na:1.8.0_111] 原因:javax.faces.FacesException:无法找到CDI BeanManager 在com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:312)〜[javax.faces-2.3.0.jar:2.3.0] 在com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:242)〜[javax.faces-2.3.0.jar:2.3.0] 在com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:484)〜[javax.faces-2.3.0.jar:2.3.0] 在com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1404)〜[javax.faces-2.3.0.jar:2.3.0] 在com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:526)〜[javax.faces-2.3.0.jar:2.3.0] 在com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256)〜[javax.faces-2.3.0.jar:2.3.0]
java.lang.RuntimeException: javax.faces.FacesException: Unable to find CDI BeanManager at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:315) ~[javax.faces-2.3.0.jar:2.3.0] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4725) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [tomcat-embed-core-8.5.5.jar:8.5.5] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-8.5.5.jar:8.5.5] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111] Caused by: javax.faces.FacesException: Unable to find CDI BeanManager at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:312) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:242) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:484) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1404) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:526) ~[javax.faces-2.3.0.jar:2.3.0] at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256) ~[javax.faces-2.3.0.jar:2.3.0]
我还将faces-config.xml
中的版本更新为2.3:
I also updated the version in my faces-config.xml
to 2.3:
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.3">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<el-resolver>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerELResolver</el-resolver>
</application>
<factory>
<exception-handler-factory>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory</exception-handler-factory>
</factory>
在pom.xml
或我的应用程序中的其他任何地方还有其他更改吗?
Are there more changes to make in the pom.xml
or anywhere else in my application?
推荐答案
旧问题,但是对于仍然面临此问题的人们:为了避免出现无法找到CDI BeanManager"错误,重要的是,您的faces-config.xml
版本是不是 2.3
,而您的web.xml
版本是不是 4.0
!
Old question, but for people still facing this problem: To avoid the "Unable to find CDI BeanManager" error, it's important that your faces-config.xml
version is not 2.3
and your web.xml
version is not 4.0
!
Mojarra实现 ELUtils类包含以下漂亮的代码:
The Mojarra implementation ELUtils class contains the following nice bit of code:
if (getFacesConfigXmlVersion(facesContext).equals("2.3") || getWebXmlVersion(facesContext).equals("4.0")) {
throw new FacesException("Unable to find CDI BeanManager");
}
在使用较低版本时,它会跳过此检查,并使用Spring DI而不是CDI.
When using lower versions, it skips this check, and works with Spring DI instead of CDI.
这篇关于如何在Spring应用程序中使用Maven将JSF 2.2更新为JSF 2.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!