title: parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml];
body: <p>I am getting a few errors in the console which I will post below. I am using eclipse and cleaned the project, refreshed the target, cleaned the tomcat server so chasing or anything of that nature is not the issue.</p>
  
  <p>Console Error:</p>
  
  <pre><code>SEVERE: Context initialization failed
  org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
      at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
      ... 21 more
  
  Apr 14, 2015 7:57:43 PM org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
      at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
      ... 21 more
  
  Apr 14, 2015 7:57:43 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Error listenerStart
  Apr 14, 2015 7:57:43 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [/offers] startup failed due to previous errors
  Apr 14, 2015 7:57:43 PM org.apache.catalina.core.ApplicationContext log
  INFO: Closing Spring root WebApplicationContext
  Apr 14, 2015 7:57:43 PM org.springframework.web.context.support.XmlWebApplicationContext doClose
  INFO: Closing Root WebApplicationContext: startup date [Tue Apr 14 19:57:43 CEST 2015]; root of context hierarchy
  Apr 14, 2015 7:57:43 PM org.springframework.web.context.support.XmlWebApplicationContext doClose
  WARNING: Exception thrown from ApplicationListener handling ContextClosedEvent
  java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Tue Apr 14 19:57:43 CEST 2015]; root of context hierarchy
      at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:344)
      at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:869)
      at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
      at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
      at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
      at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4813)
      at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5413)
      at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  Apr 14, 2015 7:57:43 PM org.springframework.web.context.support.XmlWebApplicationContext doClose
  WARNING: Exception thrown from LifecycleProcessor on context close
  java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Tue Apr 14 19:57:43 CEST 2015]; root of context hierarchy
      at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:357)
      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:877)
      at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
      at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
      at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
      at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4813)
      at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5413)
      at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  Apr 14, 2015 7:57:43 PM org.apache.catalina.core.StandardContext listenerStop
  SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
  java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
      at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
      at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:908)
      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:884)
      at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
      at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
      at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
      at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4813)
      at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5413)
      at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  Apr 14, 2015 7:57:43 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-nio-8080"]
  Apr 14, 2015 7:57:43 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-nio-8009"]
  Apr 14, 2015 7:57:43 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 2475 ms
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      id="WebApp_ID" version="3.0"&gt;
      &lt;display-name&gt;Spring_Project&lt;/display-name&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
          &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
          &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
          &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
          &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
      &lt;servlet&gt;
          &lt;description&gt;offers&lt;/description&gt;
          &lt;display-name&gt;offers&lt;/display-name&gt;
          &lt;servlet-name&gt;offers&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;offers&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;description&gt;Database&lt;/description&gt;
      &lt;resource-ref&gt;
          &lt;description&gt;DB Connection&lt;/description&gt;
          &lt;res-ref-name&gt;jdbc/Spring_Tutorial&lt;/res-ref-name&gt;
          &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
          &lt;res-auth&gt;Container&lt;/res-auth&gt;
      &lt;/resource-ref&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;ContextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              classpath:com/learnspring/config/daoContext.xml
              classpath:com/learnspring/config/offersService.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt;
  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>daoContext.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jee="http://www.springframework.org/schema/jee"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"&gt;
  
  
  
      &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
      &lt;context:component-scan
          base-package="com.learnspring.datasource.DAO"&gt;
      &lt;/context:component-scan&gt;
      &lt;jee:jndi-lookup jndi-name="jdbc/Spring_Tutorial" id="dataSource"
          expected-type="javax.sql.DataSource"&gt;
      &lt;/jee:jndi-lookup&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>offersService</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"&gt;
  
  
      &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
      &lt;context:component-scan base-package="com.learnspring.service"&gt;&lt;/context:component-scan&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>offersController</p>
  
  <pre><code>package com.learnspring.controller;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  import com.learnspring.datasource.DAO.Offer;
  import com.learnspring.service.OffersService;
  
  @Controller
  public class OffersController {
  
      private OffersService offersService;
  
      @Autowired
      public void setOffersService(OffersService offersService) {
          this.offersService = offersService;
      }
  
      @RequestMapping("/")
      public String getHome(Model model) {
  
          List&lt;Offer&gt; offers = offersService.getCurrent();
  
          model.addAttribute("offers", offers);
          return "home";
      }
  
  }
  </code></pre>
  
  <p>offersService.java</p>
  
  <pre><code>package com.learnspring.service;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import com.learnspring.datasource.DAO.Offer;
  import com.learnspring.datasource.DAO.OfferDAO;
  
  @Service("offersService")
  public class OffersService {
  
      private OfferDAO offerDAO;
  
      @Autowired
      public void setOfferDAO(OfferDAO offerDAO) {
          this.offerDAO = offerDAO;
      }
  
  
  
      public List&lt;Offer&gt; getCurrent() {
  
          return offerDAO.getOffers();
      }
  
  }
  </code></pre>
  
  <p>home.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      Hello World from JSP...
  
      &lt;c:forEach var="row" items="${offers}"&gt;
      Id ${row.id}&lt;br /&gt;
      Name ${row.name}&lt;br /&gt;
      Name ${row.email}&lt;br /&gt;
      Name ${row.text}&lt;br /&gt;
      &lt;/c:forEach&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>