Announcement Announcement Module
Collapse
No announcement yet.
PropertyPlaceholderConfigurer not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PropertyPlaceholderConfigurer not working

    I'm trying to get the PropertyPlaceholderConfigurer to work. I'm using Spring 1.2.2. My application context is as follows:

    Code:
    <beans>
        <!-- property placeholder post-processor -->
        <bean id="propertyConfigurer"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath&#58;jdbc.properties</value>
                </list>
            </property>
        </bean>
    	<bean id="dataSource" autowire="no"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName">
    			<value>com.mysql.jdbc.Driver</value>
    		</property>
    		<property name="url">
    			<value>jdbc&#58;mysql&#58;//$&#123;jdbc.host&#125;/$&#123;jdbc.dbname&#125;</value>
    		</property>
    		<property name="username">
    			<value>$&#123;jdbc.username&#125;</value>
    		</property>
    		<property name="password">
    			<value>$&#123;jdbc.password&#125;</value>
    		</property>
    	</bean>
    ...
    In WEB-INF/classes, I have a file called jdbc.properties:
    Code:
    # The JDBC settings
    jdbc.username=devbox
    jdbc.password=devbox
    jdbc.dbname=devbox
    jdbc.host=localhost
    ...but, the properties don't seem to be substituted. I get the following error

    ...
    Code:
    WARN - JDBCExceptionReporter.logExceptions&#40;71&#41; | SQL Error&#58; 0, SQLState&#58; 08S01
    ERROR - JDBCExceptionReporter.logExceptions&#40;72&#41; | Unable to connect to any hosts due to exception&#58; java.net.UnknownHostException&#58; $&#123;jdbc.host&#125;
    I've read through other postings on similar topics, and I understand that the automatic substitution only occurs for an application context, not a bean factory. But since these definitions are defined in the application context (and being loaded by the serlvet container automatically, doesn't that imply that I'm using the application context?

    Thanks for any help and enlightenment...

  • #2
    oops...wrong place

    Oops. I mean to place this in the core container forum. I'll repost it there. Please ignore this post. My apologies.

    Comment

    Working...
    X