title: Confused about using ContextLoaderListener in Spring MVC
body: <p>I am reading a book on Spring and Spring MVC, and am trying out the sample application. The problem is that it's a pre-release version of the book, and the full code isn't available to download yet.</p>
  
  <p>I want the beans from my service layer to be accessible via the web app. Do I have to declare them in two xml files? (One for the service layer, and one for the web app?) This code is given in the book to add to the web.xml file, but I am unsure what this solves:</p>
  
  <pre><code>&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;
            /WEB-INF/spitter-security.xml
            classpath:service-context.xml
            classpath:persistence-context.xml
            classpath:dataSource-context.xml
         &lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>But it does not say where the service-context.xml etc files are located, or what the folder structure is. How do they get on the classpath to be accessed by "classpath:"?</p>
  
  <p>Can I have this xml file in one location to be accessed both by the main application and by the web application? Or do I need to declare my beans twice for when it gets deployed to Tomcat?</p>
  
  <p>Any help would be appreciated as I am really confused about this. Thanks</p>