Announcement Announcement Module
No announcement yet.
Problem getting System Environment variable Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem getting System Environment variable


    I want load different database properties for different environment based on a System Environment Property 'ENV'. I was trying it by putting ${ENV}
    as shown below :

    :- part from my applicationContext.xml
    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location">

    <bean id="hibDataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName"><value>${driverClassName}</value></property>
    <property name="url">
    <property name="username"><value>${username}</value></property>
    <property name="password"><value>${password}</value></property>

    But I am getting exception since the SystemPropertyUtil class used by Spring framework to resolve place holders uses System.getEnv() which is deprecated and thus I get an exception : "getenv no longer supported, use properties and -D instead: " + ENV

    Is there any other way I can get this property value ?

    Also I tried setting Tomcat Environment variable for my application so that I can pick up the value of 'ENV' from there but not able to get it . Any suggestion How can I get Environment varaible set in Tomcat in my applicationContext.xml

    A quick help would be highly appreciated.

    Thanks in advance to all.

  • #2
    What JDK are you using? It was deprecated in 1.4 but I think it's ok in 1.5.
    Last edited by karldmoore; Aug 29th, 2007, 11:52 AM.


    • #3
      Hi karldmoore

      Thanks for the reply, I want to get workaround in jdk1.4.2 as i need to code for jdk 1.4.2.