title: java.io.FileNotFoundException: class path resource [WEB-INF/classes/library.properties] cannot be opened because it does not exist
body: <p>In my Spring application, I have a simple properties file located in folder <code>WEB-INF\classes</code> so that it, the <code>DispatcherServlet</code> and various other config files are in the <code>classpath</code>.</p>
  
  <p>The props file is defined in the <code>DispatcherServlet</code> as:</p>
  
  <pre><code>&lt;bean id="propertiesFactory" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt;
          &lt;property name="location"&gt;            
             &lt;value&gt;/WEB-INF/classes/library.properties&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>The <code>propertiesFactory</code> bean is injected into a controller:</p>
  
  <pre><code>@Autowired 
  private Properties propertiesFactory;
  </code></pre>
  
  <p>And used in a one of the controller's methods as:</p>
  
  <pre><code>if (adminPassword.equals(propertiesFactory.getProperty("adminPassword"))) {           
  </code></pre>
  
  <p>This all works perfectly, except for a test program as follows which has line:</p>
  
  <pre><code>ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("library-servlet.xml");
  </code></pre>
  
  <p>Which throws a <code>BeanCreationException</code>:  </p>
  
  <pre><code>Injection of autowired dependencies failed
  </code></pre>
  
  <p>Because of:</p>
  
  <pre><code>java.io.FileNotFoundException: class path resource [WEB-INF/classes/library.properties] cannot be opened because it does not exist
  </code></pre>
  
  <p>But if the whole application can see the props file, why not this one program?</p>