title: SpringSource: loading properties PropertyPlaceholderConfigurer bean
body: <p>I'm using Spring Tool Suite Version: 3.0.0.RELEASE</p>
  
  <p>I want to load my own .properties files to use in my application, so I tried using PropertyPlaceholderConfigurer </p>
  
  <p>Here is my servlet-context.xml code:</p>
  
  <pre><code>     &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      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"&gt;
  
      &lt;!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --&gt;
  
      &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
      &lt;annotation-driven /&gt;
  
      &lt;!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --&gt;
      &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
      &lt;!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --&gt;
      &lt;beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
          &lt;beans:property name="suffix" value=".jsp" /&gt;
      &lt;/beans:bean&gt;
      &lt;context:component-scan base-package="jp.co.rns" /&gt;
  
      &lt;mvc:interceptors&gt;
      &lt;beans:bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
          &lt;beans:property name="paramName" value="lang" /&gt;
      &lt;/beans:bean&gt;
  &lt;/mvc:interceptors&gt;
  
      &lt;beans:bean id="messageSource"
      class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
      &lt;beans:property name="basename" value="classpath:static" /&gt;
      &lt;beans:property name="defaultEncoding" value="UTF-8"/&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="localeChangeInterceptor"
      class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
      &lt;beans:property name="paramName" value="lang" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="localeResolver"
      class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt;
      &lt;beans:property name="defaultLocale" value="jp"/&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="handlerMapping"
      class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt;
      &lt;beans:property name="interceptors"&gt;
          &lt;beans:ref bean="localeChangeInterceptor" /&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="propertyConfigurer" 
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; 
      &lt;beans:property name="location"&gt;
       &lt;beans:value&gt;application.properties&lt;/beans:value&gt; 
      &lt;/beans:property&gt;
      &lt;beans:property name="ignoreUnresolvablePlaceholders"&gt;
      &lt;beans:value&gt;true&lt;/beans:value&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>application.properties:</p>
  
  <pre><code>order=2
  companyName=Unknown
  </code></pre>
  
  <p>Project structure:</p>
  
  <pre><code>src
  |
   ---main
  |  |
  |   ---java
  |  |
  |   ---resources
  |  |
  |   ---webapp
  |      |
  |       ---application.properties
  |      |
  |       ---resources
  |      |   |
  |      |    ---application.properties    
  |      |
  |       ---WEB-INF
  |          |
  |           ---application.properties 
  |          |
  |           ---web.xml
  |          |
  |           ---classes (empty)
  |          |
  |           ---spring
  |          |   |
  |          |    ---application.properties
  |          |   |
  |          |    ---root-context.xml
  |          |   |
  |          |    ---appServlet
  |          |       |
  |          |        ---servlet-context.xml
  |          |       |
  |          |        ---application.properties
  |          |
  |           ---views (...)
  |
   ---test
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Processes application requests --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I checked, application.properties IS in /WEB-INF/ directory.</p>
  
  <p>But when I start to start server, it gives me an error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/application.properties]
  </code></pre>
  
  <p>What am I doing wrong?</p>