title: ClassPathResource cannot access my spring properties file (using Spring web MVC)
body: <p>The actual location of the file is in "D:\eclipse\projects\issu\src\main\webapp\WEB-INF\spring\spring.properties"</p>
  
  <p>I tried:</p>
  
  <pre><code>Resource resource = new ClassPathResource("/src/main/webapp/WEB-INF/spring/spring.properties");
  
  Resource resource = new ClassPathResource("/WEB-INF/spring/spring.properties");
  
  Resource resource = new ClassPathResource("classpath:/WEB-INF/spring/spring.properties");
  </code></pre>
  
  <p>I also have added "/src/main/webapp" folder to my build path.</p>
  
  <p>ClassPathResource cannot find it. Any ideas? thanks! :)</p>
  
  <p><strong>my web.xml</strong></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"
      xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;ISSU&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;spring&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/spring-servlet.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;spring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>my spring-servlet.xml</strong></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"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:tx="http://www.springframework.org/schema/tx"
      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.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"&gt;
  
      &lt;context:component-scan base-package="com.myapps.issu" /&gt;
  
      &lt;mvc:annotation-driven /&gt;
      &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  
      &lt;tx:annotation-driven /&gt;
  
      &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="location" value="/WEB-INF/spring/spring.properties" /&gt;
      &lt;/bean&gt;
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="${jdbc.driverClassName}" /&gt;
          &lt;property name="url" value="${jdbc.databaseurl}" /&gt;
          &lt;property name="username" value="${jdbc.username}" /&gt;
          &lt;property name="password" value="${jdbc.password}" /&gt;
      &lt;/bean&gt;
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="configLocation" value="${hibernate.config}" /&gt;
          &lt;property name="packagesToScan" value="com.myapps.issu" /&gt;
      &lt;/bean&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
          &lt;property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" /&gt;
      &lt;/bean&gt;
      &lt;bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;
          &lt;property name="definitions" value="/WEB-INF/tiles.xml" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="issuDao" class="com.myapps.issu.dao.IssuDaoImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
      &lt;bean id="issuService" class="com.myapps.issu.services.IssuServiceImpl"&gt;
          &lt;property name="issuDao" ref="issuDao" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>