title: Spring loading PropertySourcesPlaceholderConfigurer from JBoss context
body: <p>I have a spring 3.1 application loading settings using PropertySourcesPlaceholderConfigurer and I want to manage test and production environments simply loading settings from server context overriding settings specified in local file properties.</p>
  
  <p>Next example works fine with Tomcat, how can I do the same in JBoss AS 7.1?</p>
  
  <p>In spring context I have:</p>
  
  <pre><code>&lt;bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"&gt;
      &lt;property name="ignoreUnresolvablePlaceholders" value="true" /&gt;
      &lt;property name="localOverride" value="false" /&gt;
      &lt;property name="locations"&gt;
          &lt;list&gt;
              &lt;value&gt;classpath:Application.properties&lt;/value&gt;
              &lt;value&gt;classpath:ApplicationTest.properties&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt;
      &lt;property name="driverClass" value="${jdbc.driverClassName}" /&gt;
      &lt;property name="jdbcUrl" value="${jdbc.url}" /&gt;
      &lt;property name="user" value="${jdbc.username}" /&gt;
      &lt;property name="password" value="${jdbc.password}" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In ApplicationTest.properties (that overrides Application.properties):</p>
  
  <pre><code>jdbc.driverClassName=oracle.jdbc.OracleDriver
  jdbc.url=jdbc:oracle:thin:@XXXX:1521:xxxx
  jdbc.username=myUsername
  jdbc.password=myPassword
  </code></pre>
  
  <p>In context.xml (in Tomcat/conf directory):</p>
  
  <pre><code>&lt;Context&gt;
      ...
      &lt;Parameter name="jdbc.driverClassName" value="oracle.jdbc.OracleDriver" override="false"/&gt;
      &lt;Parameter name="jdbc.url" value="jdbc:oracle:thin:@XXXX:1521:ProductionSID" override="false"/&gt;
      &lt;Parameter name="jdbc.username" value="myProductionUsername" override="false"/&gt;
      &lt;Parameter name="jdbc.password" value="myProductionPassword" override="false"/&gt;
      ...
  &lt;/Context&gt;
  </code></pre>
  
  <p>In this way all parameters specified in context.xml overrides parameters in ApplicationTest.properties.</p>
  
  <p>Is there a way to specify context parameter in JBoss? (i.e. in standalone.xml file)</p>
  
  <p><strong>EDIT - SOLVED:</strong></p>
  
  <p>As suggested in the answers, if I put entries in WEB-INF/jboss-web.xml inside webapp that works:</p>
  
  <pre><code>&lt;jboss-web&gt;
  ...
      &lt;env-entry&gt;
          &lt;env-entry-name&gt;jdbc.username&lt;/env-entry-name&gt;
          &lt;env-entry-value&gt;myUsername&lt;/env-entry-value&gt;
          &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
      &lt;/env-entry&gt;
  ...
  &lt;/jboss-web&gt;
  </code></pre>
  
  <p>But my goal was to put the config file out of webapp.
  I solved in this way, I load the config file from $SERVER/conf directory:</p>
  
  <pre><code>&lt;bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"&gt;
      &lt;property name="ignoreUnresolvablePlaceholders" value="false" /&gt;
      &lt;property name="localOverride" value="false" /&gt;
      &lt;property name="ignoreResourceNotFound" value="true" /&gt;
      &lt;property name="locations"&gt;
          &lt;list&gt;
              &lt;value&gt;classpath:Application.properties&lt;/value&gt;
              &lt;value&gt;classpath:ApplicationTEST.properties&lt;/value&gt;
              &lt;value&gt;file:${catalina.home}\conf\ApplicationPRODUCTION.properties&lt;/value&gt;&lt;!-- FOR TOMCAT --&gt;
              &lt;value&gt;file:${jboss.server.base.dir}\configuration\ApplicationPRODUCTION.properties&lt;/value&gt;&lt;!-- FOR JBOSS--&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>If someone knows how to put Parameters in JBOSS config out of webapp (as TOMCAT) is well appreciated!</p>
  
  <p>Thanks All!</p>