Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring - No WebApplicationContext found: no ContextLoaderListener registered? [duplicate]

I am getting the following error while trying to run a Spring project

HTTP Status 500 - java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?

Inspite of adding the listner on to my web.xml. I am still getting this error. Below is the listener I have added to my web.xml :

 <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/HelloWebRedirect-servlet.xml</param-value>
 </context-param> 

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

Can someone help me out in this regard?

like image 951
user2681868 Avatar asked Sep 02 '13 09:09

user2681868


2 Answers

Hi @user2681868 I was also facing the same problem here are the steps you should follow.

1) in web.xml define this

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

2) create a applicationContext.xml in web-inf with this content

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    </beans>
like image 143
Pulkit Avatar answered Oct 09 '22 04:10

Pulkit


Try like this

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> 
like image 36
shazin Avatar answered Oct 09 '22 04:10

shazin