title: Properties file not getting loaded
body: <p>I have Two projects, CarpoolDB and Carpool.</p>
  
  <p>CarpoolDB : contains backend stuff and has </p>
  
  <p>carpool-application-context.xml</p>
  
  <pre><code>&lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.onmobile" /&gt;
  &lt;context:property-placeholder location="classpath:server.properties" /&gt;
  </code></pre>
  
  <p>server.properties</p>
  
  <pre><code>cm.db.driverClassName=com.mysql.jdbc.Driver
  cm.db.url=jdbc:mysql://localhost:3306/carpool1
  cm.db.username=abc
  cm.db.password=xyz
  </code></pre>
  
  <p>I make a jar of carpoolDB and place in Carpool Application</p>
  
  <p>Carpool: contains UI thing and for backend contact carpoolDB jar and has</p>
  
  <p>carpool-application-context1.xml</p>
  
  <pre><code>&lt;import resource="classpath:carpool-application-context.xml"/&gt;
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.onmobile.carpool.authentication" /&gt;
  </code></pre>
  
  <p>spring-servlet.xml</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:carpool.properties" /&gt; 
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.onmobile.carpool.controller, com.onmobile.carpool.util" /&gt;
  </code></pre>
  
  <p>carpool.properties</p>
  
  <pre><code>cm.email.sender.mail.smtp.host=mail.on.com
  </code></pre>
  
  <p>Now, I have one class com.onmobile.carpool.util.EmailSender, it has one property smtpHost and want the value to get injected by Spring using @Value but it is not getting injected.</p>
  
  <pre><code>@Controller
  public class EmailSender {
  
      public static final Log logger = LogFactory.getLog(EmailSender.class);
  
      @Value("${cm.email.sender.mail.smtp.host}")
      private String smtpHost;
  
  }
  </code></pre>
  
  <p>I am getting error as  </p>
  
  <pre><code>java.lang.IllegalArgumentException: Could not resolve placeholder 'cm.email.sender.mail.smtp.host'
  </code></pre>
  
  <p>carpool.properties is present in src folder.</p>
  
  <p>Why it is not picking the cm.email.sender.mail.smtp.host from carpool.properties file. is there any relation with properties file present in jar file.</p>
  
  <p>Actually properties file is loaded as I can't see in logs like file not found but field is not getting autowired.</p>
  
  <hr>
  
  <hr>
  
  <p>Posting updated complete configuration files after removing import</p>
  
  <p>web.xml</p>
  
  <pre><code>  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
              /WEB-INF/carpool-application-context1.xml
              /WEB-INF/applicationContext-security.xml
          &lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;
              org.springframework.web.filter.DelegatingFilterProxy
          &lt;/filter-class&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&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;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;/jsp/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;
      org.springframework.web.context.ContextLoaderListener
      &lt;/listener-class&gt;
    &lt;/listener&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;
          org.springframework.security.web.session.HttpSessionEventPublisher
          &lt;/listener-class&gt;
    &lt;/listener&gt;
  </code></pre>
  
  <p>carpool-application-context1.xml</p>
  
  <pre><code>&lt;!-- Configure annotated beans --&gt; 
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.onmobile.carpooldb.db" /&gt;
  &lt;context:property-placeholder location="classpath:carpool.properties" /&gt;
  
  
     &lt;beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;beans:property name="driverClassName"&gt;&lt;beans:value&gt;${cm.db.driverClassName}&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="url"&gt;&lt;beans:value&gt;${cm.db.url}&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="username"&gt;&lt;beans:value&gt;${cm.db.username}&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="password"&gt;&lt;beans:value&gt;${cm.db.password}&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="testOnBorrow"&gt;&lt;beans:value&gt;true&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="testOnReturn"&gt;&lt;beans:value&gt;true&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="validationQuery"&gt;&lt;beans:value&gt;select 1&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="maxIdle"&gt;&lt;beans:value&gt;-1&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="maxActive"&gt;&lt;beans:value&gt;-1&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="maxOpenPreparedStatements"&gt;&lt;beans:value&gt;-1&lt;/beans:value&gt;&lt;/beans:property&gt;
          &lt;beans:property name="maxWait"&gt;&lt;beans:value&gt;30000&lt;/beans:value&gt;&lt;/beans:property&gt;
      &lt;/beans:bean&gt;
  
      //session factory bean and other configuration 
  </code></pre>
  
  <p>spring-servlet.xml</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:carpool.properties" /&gt;
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.onmobile.carpool.authentication, com.onmobile.carpool.controller, com.onmobile.carpool.util" /&gt;
  
  
  &lt;!-- Declare a view resolver --&gt;
  &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
  p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /&gt;
  
  &lt;bean id="multipartResolver"
      class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
  
      &lt;!-- one of the properties available; the maximum file size in bytes --&gt;
      &lt;property name="maxUploadSize" value="100000"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>carpool.properties</p>
  
  <pre><code>cm.db.driverClassName=com.mysql.jdbc.Driver
  cm.db.url=jdbc:mysql://localhost:3306/carpool
  cm.db.username=abc
  cm.db.password=xyz
  
  user.profile.pic.base.folder=D:\\carpoolRepository\\carpoolProfilePicUpload
  google.places.autocomplete.response.xml.base.folder=D:\\carpoolRepository\\googleMapXML
  
  #EMAIL - FORGOT PASSWORD 
  cm.email.sender.mail.smtp.host=mail.on.com
  </code></pre>
  
  <p>I am trying to inject value of  cm.email.sender.mail.smtp.host in EmailSender "smtpHost" property way mentioned above, when i read it it says null.
  other properties like cm.db.driverClassName etc get properly injected in carpool-application-context1.xml.</p>
  
  <p>I am attaching the snap containing location for configuration files<img src="https://i.stack.imgur.com/5FyKJ.png" alt="enter image description here"></p>