title: How to register Spring @Configuration annotated class instead of applicationContext.xml file in web.xml?
body: <p>I am using jsf and spring together in web application. I have configured datasource and session factory in one configuration class which uses annotations like <code>@Configuration, @ComponentScan</code> etc. <strong>I don't have any applicationContext.xml file in my project</strong> as I am handling every entry of context xml in Configuration class. The test case works successfully but when I deploy my web application, it gives me error </p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: No WebApplicationContext found: no
    ContextLoaderListener registered?</p>
  </blockquote>
  
  <p>Now if I give listener class in web.xml,</p>
  
  <pre><code>&lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  </code></pre>
  
  <p>it gives me error, </p>
  
  <blockquote>
    <p>/WEB-INF/applicationContext.xml not found</p>
  </blockquote>
  
  <p>As per the document of <code>ContextLoaderListener</code>, it's true that if I don't give <code>contextConfigLocation</code> param in <code>web.xml</code> explicitly, it will search for the default spring context file named <code>applicationContext.xml</code> in <code>web.xml</code>. Now, what should I do if I don't want to use spring context file and do all the configuration with annotations? How should I register listener class <code>ContextLoaderListener</code> so that without use of xml file and using annotations only, I be able to run my web application with spring and jsf?</p>