title: Adding properties file to classpath but getting a FileNotFoundException
body: <p>My spring context file has this:</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:web.properties" /&gt;
  </code></pre>
  
  <p>and I reference the key/values like:</p>
  
  <pre><code>&lt;property name="username" value="${dataSource.username}"/&gt;
  </code></pre>
  
  <p>My file layout is like:</p>
  
  <pre><code>&gt;/www/site/app.war
  &gt;/www/site/configs/web.properties
  </code></pre>
  
  <p>And I run my app using:</p>
  
  <pre><code>&gt;java -cp "/www/site/configs/*.*" -jar app.war
  </code></pre>
  
  <p>But then I get this exception:</p>
  
  <pre><code>java.io.FileNotFoundException: class path resource [web.properties] cannot be opened because it does not exist
      at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
      at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
      at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
      at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:661)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
      at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
  </code></pre>
  
  <p>Even though I added the files to my classpath, it still can't find it why?</p>
  
  <p><b>Update</b></p>
  
  <p>So my config files are here:</p>
  
  <pre><code>/www/site/configs/web.properties
  /www/site/configs/log4j.properties
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>&gt;/www/site/java -cp ".:app.war:/www/site/configs/*.*" com.abc.server.MyServer
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>&gt;/www/site/java -cp ".:app.war:/www/site/configs/web.properties:/www/site/configs/log4j.properties" com.abc.server.MyServer
  </code></pre>
  
  <p>and even:</p>
  
  <blockquote>
    <p>/www/site/java -cp ".:app.war" com.abc.server.MyServer</p>
  </blockquote>
  
  <p>I get the same error:</p>
  
  <pre><code>2013-04-25 01:19:28.210:INFO:oejs.Server:jetty-7.x.y-SNAPSHOT
  2013-04-25 01:19:28.294:INFO:oejw.WebInfConfiguration:Extract jar:file:/www/site/app.war!/ to /www/site/work/app
  2013-04-25 01:19:32.814:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/www/site/app/},file:/www/site/app.war
  log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
  log4j:WARN Please initialize the log4j system properly.
  log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  2013-04-25 01:19:33.585:INFO:/:Initializing Spring FrameworkServlet 'app'
  2013-04-25 01:19:35.750:WARN:/:unavailable
  org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in ServletContext resource [/WEB-INF/web-context.xml]: Could not resolve placeholder 'dataSource.url' in string value [${dataSource.url}]
      at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
  </code></pre>
  
  <p>My web.properties has:</p>
  
  <pre><code>dataSource.url=jdbc:mysql://localhost/appdb
  dataSource.username=root
  dataSource.password=123
  </code></pre>
  
  <p>Again my web-context.xml file has:</p>
  
  <pre><code>..
   &lt;context:property-placeholder location="classpath*:/web.properties" /&gt;
  
      &lt;bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
          &lt;property name="url" value="${dataSource.url}"/&gt;
          &lt;property name="username" value="${dataSource.username}"/&gt;
          &lt;property name="password" value="${dataSource.password}"/&gt;
  ..
  </code></pre>
  
  <p>I also tried the following variations:</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:web.properties" /&gt;
  &lt;context:property-placeholder location="classpath*:web.properties" /&gt;
  &lt;context:property-placeholder location="classpath*:/web.properties" /&gt;
  </code></pre>