No WebApplicationContext found: no ContextLoaderListener registered? [duplicate]

孤街醉人 提交于 2019-12-11 06:41:42

问题


I was able to load any xhtml page when I was using JSF and then I thought to add spring. I went to the documentation jsf spring integration and added el-resolver in my faces-config.xml:

<?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>

now when I am trying to load the page it's giving the error:

javax.servlet.ServletException: No WebApplicationContext found: no ContextLoaderListener registered? javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)


回答1:


You have to add org.springframework.web.context.ContextLoaderListener listener in your WEB-INF\web.xml

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>



回答2:


The solution was:

  1. I was not including applicationContext in my WEB-INF folder.
  2. Spring-asm-3.1.4 was conflicting.

You don't need spring asm if you are using spring version higher than 3.2, as it's included in spring-core. It conflicts with the spring-core and throw other exceptions.



来源:https://stackoverflow.com/questions/27015057/no-webapplicationcontext-found-no-contextloaderlistener-registered

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!