title: Spring 3.1.1 Placeholder failure in WebSphere 8.5.5
body: <p>I have a spring application deployed to a WebSphere 8.5.5 installation that has an issue where it occassionally starts up and fails to load the property file subsitutions.  After a few restarts, it will pick up the place holder values and properly start up.  When it fails to pick up the values, it results in a stack trace error similar the snippet I'll be adding to the bottom of this post.</p>
  
  <p>We've contacted IBM Support, but they believe it to be a Spring Framework Placeholder Configurer issue after their investigation of our collected logs.  I've also attached a snippet of our bean configuration for reference.  Is this a known issue in Spring?  Any help would be greatly appreciated.</p>
  
  <p>STACK TRACE ERROR:</p>
  
  <pre><code>[9/29/16 9:28:57:197 CDT] 000000e0 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper init Uncaught.init.exception.thrown.by.servlet
  [9/29/16 9:28:57:199 CDT] 000000e0 webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[apiWeb]: org.springframework.beans.fa
  ctory.BeanDefinitionStoreException: Invalid bean definition with name 'mailSender' defined in class path resource [spring-mailsender.xml]: Could not resolve placeholder '
  mailsender.host' in string value "${mailsender.host}"
          at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
          at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.processProperties(PropertySourcesPlaceholderConfigurer.java:174)
          at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:151)
          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:662)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
          at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1709)
          at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:414)
          at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
          at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:170)
          at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:904)
          at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789)
          at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427)
          at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719)
          at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1178)
          at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1383)
          at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
          at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:972)
          at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
          at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.processProperties(PropertySourcesPlaceholderConfigurer.java:174)
          at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:151)
          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:662)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
          at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1709)
          at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:414)
          at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
          at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:170)
          at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:904)
          at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789)
          at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427)
          at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719)
          at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1178)
          at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1383)
          at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
  </code></pre>
  
  <p>BEAN DEFINITION:</p>
  
  <pre><code>&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
  
      &lt;property name="location"&gt;
  
          &lt;!-- This factory bean will provide a classpath resource pointing to 
              environment/[env].properties, e.g. environment/dev.properties. 
              It will get the name of the environment from the Java system
              property runtime.environment. --&gt;
          &lt;bean class="com.czr.ocrm.integration.util.EnvPropertiesResourceFactory"&gt;
              &lt;property name="systemPropertyName" value="runtime.environment"/&gt;
              &lt;property name="propertiesFilePrefix" value="environment/"/&gt;
              &lt;property name="defaultEnvironment" value="dev"/&gt;
              &lt;property name="propertiesFileSuffix" value=".properties"/&gt;
          &lt;/bean&gt;
  
      &lt;/property&gt;
  
      &lt;property name="ignoreUnresolvablePlaceholders" value="true"/&gt;
  
      &lt;!-- This setting means any properties set using Java system properties will
          override what is in the properties file. --&gt;
      &lt;property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/&gt;
  
      &lt;!-- Lowest priority so the containing app can override --&gt;
      &lt;property name="order" value="9999"&gt;&lt;/property&gt; 
  &lt;/bean&gt;
  </code></pre>