找不到WebApplicationContext:没有注册ContextLoaderListener?

时间:2014-11-19 10:54:33

标签: java spring jsf jsf-2

当我使用JSF时,我能够加载任何xhtml页面,然后我想添加spring。我转到文档jsf spring integration并在我的faces-config.xml中添加了el-resolver:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
        <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
        </application>
</faces-config>

现在,当我尝试加载页面时,它会给出错误:

  

javax.servlet.ServletException:找不到WebApplicationContext:否   ContextLoaderListener注册了吗?     javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)

2 个答案:

答案 0 :(得分:3)

您必须在org.springframework.web.context.ContextLoaderListener

中添加WEB-INF\web.xml侦听器
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

答案 1 :(得分:0)

解决方案是:

  1. 我没有在我的WEB-INF文件夹中包含applicationContext。
  2. Spring-asm-3.1.4存在冲突。
  3. 如果使用高于3.2的弹簧版本,则不需要弹簧asm,因为它包含在弹簧芯中。它与spring-core冲突并抛出其他例外。