Results 1 to 2 of 2

Thread: PropertyPlaceholderConfigurer not working

  1. #1
    Join Date
    Mar 2005
    Posts
    7

    Default 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. #2
    Join Date
    Mar 2005
    Posts
    7

    Default 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.

Similar Threads

  1. Replies: 7
    Last Post: Jan 8th, 2013, 04:05 AM
  2. Jboss, JAAS, Spring -- working example?
    By jkwon in forum Security
    Replies: 4
    Last Post: May 14th, 2009, 03:41 PM
  3. Replies: 1
    Last Post: Jan 20th, 2009, 11:50 AM
  4. Replies: 1
    Last Post: Oct 6th, 2005, 10:32 AM
  5. Replies: 2
    Last Post: Apr 22nd, 2005, 09:16 AM

Posting Permissions

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