Results 1 to 6 of 6

Thread: System properties and PropertyPlaceholderConfigurer

  1. #1
    Join Date
    Aug 2004
    Posts
    123

    Default System properties and PropertyPlaceholderConfigurer

    I've been playing around with Spring+Hibernate with an hsqldb database. If you want to run hsqld standalone, you need to specify the URL in the form:

    jdbc:hsqldb:file:/full/path/to/database/directory

    As this is obviously not something I'd want to 'hard code', I thought I'd try to use a path relative to the home directory, as contained in the system property 'user.dir'. So, in the datasource section of my applicationContext.xml, I tried the following:

    <property name="url">
    <value>jdbc:hsqldb:file:${user.dir}/WEB-INF/db/db</value>
    </property>

    Unfortunately, when I tried to use this URL, it showed up without any replacement, i.e., as:

    jdbc:hsqldb:file:${user.dir}/WEB-INF/db/db</value

    Is there something else I have to do?

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    PropertyPlaceholderConfigurer does not support System Properties. You can however "hard code" the path inside a jdbc.properties file.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Posts
    123

    Default

    Quote Originally Posted by irbouho
    PropertyPlaceholderConfigurer does not support System Properties. You can however "hard code" the path inside a jdbc.properties file.
    According to the Javadoc for PropertyPlaceholderConfigurer:

    'A configurer will also check against system properties (e.g. "user.dir") if it cannot resolve a placeholder with any of the specified properties. This can be customized via "systemPropertiesMode".'

    Theer's no explanation of how this customizing is done, but I tried this:

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="systemPropertiesMode">
    <value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
    </property>
    </bean>

    Unfortunately this just gave me the following:

    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [int] for property 'systemPropertiesMode'; nested exception is java.lang.NumberFormatException: For input string: "SYSTEM_PROPERTIES_MODE_OVERRIDE"

    I may have to fall back to the jdbc.properties approach, although I would like to make this really dynamic.

  4. #4
    Join Date
    Aug 2004
    Posts
    123

    Default

    I believe I have solved the problem myself, by the addition of the following to the applicationContext.xml:

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer"/>

    I had wrongly believed that there was a default configurer.

  5. #5
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Very strange, I had posted a reply in here that PropertyPlaceholderConfigurer does support use of System properties, but it seems to have vanished.

    The System properties can be considered either before or afte the ones coming from the Properties file.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  6. #6
    Join Date
    Aug 2004
    Posts
    123

    Default

    I think it does support the use of system properties. I don't believe that was my problem.

Similar Threads

  1. FlowExecutionStorage in a DB
    By cacho in forum Web Flow
    Replies: 7
    Last Post: Oct 19th, 2009, 03:36 PM
  2. How to use system properties in a BeanFactory?
    By smcardle in forum Container
    Replies: 1
    Last Post: Oct 20th, 2005, 01:22 PM
  3. Replies: 1
    Last Post: Jun 15th, 2005, 11:25 AM
  4. Initializing beans based on system properties
    By garpinc2 in forum Container
    Replies: 8
    Last Post: Dec 1st, 2004, 04:44 PM
  5. Replies: 19
    Last Post: Oct 20th, 2004, 11:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •