Results 1 to 5 of 5

Thread: Upgraded to 2.0, PropertyPlaceholderConfigurer problems

Hybrid View

  1. #1

    Default Upgraded to 2.0, PropertyPlaceholderConfigurer problems

    I just upgraded from 1.2.6 to 2.0-M5 and now I'm getting an exception from DriverManagerDataSource becuase it seems that PropertyPlaceholderConfigurer didn't substitute it's values.

    Here's the relevent config:
    Code:
    <beans>
      <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/jdbc.properties</value>
                </list>
            </property>
      </bean>
      
      <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="url">
            <value>${jdbc.url}</value>
        </property>
        <property name="driverClassName">
            <value>${jdbc.driverClassName}</value>
        </property>
        <property name="username">
            <value>${jdbc.username}</value>
        </property>
        <property name="password">
            <value>${jdbc.password}</value>
        </property>
      </bean>
    ...  
    </beans>
    And here's the log output:

    org.springframework.beans.factory.support.DefaultL istableBeanFactory: Invoking BeanPostProcessors before instantiation of bean 'dataSource'
    org.springframework.beans.CachedIntrospectionResul ts: Getting BeanInfo for class [org.springframework.jdbc.datasource.DriverManagerD ataSource]
    org.springframework.beans.CachedIntrospectionResul ts: Caching PropertyDescriptors for class [org.springframework.jdbc.datasource.DriverManagerD ataSource]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'class' of type [java.lang.Class]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'connection' of type [java.sql.Connection]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'connectionProperties' of type [java.util.Properties]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'driverClassName' of type [java.lang.String]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'logWriter' of type [java.io.PrintWriter]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'loginTimeout' of type [int]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'password' of type [java.lang.String]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'url' of type [java.lang.String]
    org.springframework.beans.CachedIntrospectionResul ts: Found property 'username' of type [java.lang.String]
    org.springframework.beans.CachedIntrospectionResul ts: Class [org.springframework.jdbc.datasource.DriverManagerD ataSource] is cache-safe
    org.springframework.core.CollectionFactory: Creating [java.util.LinkedHashMap]
    org.springframework.beans.factory.support.DefaultL istableBeanFactory: Eagerly caching bean with name 'dataSource' to allow for resolving potential circular references
    org.springframework.beans.BeanWrapperImpl: About to invoke write method [public void org.springframework.jdbc.datasource.DriverManagerD ataSource.setUrl(java.lang.String)] on object of class [org.springframework.jdbc.datasource.DriverManagerD ataSource]
    org.springframework.beans.BeanWrapperImpl: Invoked write method [public void org.springframework.jdbc.datasource.DriverManagerD ataSource.setUrl(java.lang.String)] with value of type [java.lang.String]
    org.springframework.beans.BeanWrapperImpl: About to invoke write method [public void org.springframework.jdbc.datasource.DriverManagerD ataSource.setDriverClassName(java.lang.String) throws org.springframework.jdbc.CannotGetJdbcConnectionEx ception] on object of class [org.springframework.jdbc.datasource.DriverManagerD ataSource]
    org.springframework.beans.BeanWrapperImpl: About to invoke write method [public void org.springframework.jdbc.datasource.DriverManagerD ataSource.setUsername(java.lang.String)] on object of class [org.springframework.jdbc.datasource.DriverManagerD ataSource]
    org.springframework.beans.BeanWrapperImpl: Invoked write method [public void org.springframework.jdbc.datasource.DriverManagerD ataSource.setUsername(java.lang.String)] with value of type [java.lang.String]
    org.springframework.beans.BeanWrapperImpl: About to invoke write method [public void org.springframework.jdbc.datasource.DriverManagerD ataSource.setPassword(java.lang.String)] on object of class [org.springframework.jdbc.datasource.DriverManagerD ataSource]
    org.springframework.beans.BeanWrapperImpl: Invoked write method [public void org.springframework.jdbc.datasource.DriverManagerD ataSource.setPassword(java.lang.String)] with value of type [java.lang.String]
    org.springframework.beans.factory.support.DefaultL istableBeanFactory: Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [...]; root of BeanFactory hierarchy}
    org.springframework.web.context.ContextLoader: Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/classes/persistence.xml]: Error setting property values; nested exception is PropertyAccessExceptionsException (1 errors)
    Caused by:
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.MethodInvocationExceptio n: Property 'driverClassName' threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionEx ception: Could not load JDBC driver class [${jdbc.driverClassName}]; nested exception is java.lang.ClassNotFoundException: ${jdbc.driverClassName}
    Caused by:
    org.springframework.jdbc.CannotGetJdbcConnectionEx ception: Could not load JDBC driver class [${jdbc.driverClassName}]; nested exception is java.lang.ClassNotFoundException: ${jdbc.driverClassName}
    Caused by:
    java.lang.ClassNotFoundException: ${jdbc.driverClassName}

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    First, is the spring config file you have posted located at: "/WEB-INF/classes/persistence.xml" ?

    Second, can you show the key/val pair for jdbc.driverClassName in the jdbc.properties file at the root of your classpath?

  3. #3

    Default

    Quote Originally Posted by Mark Fisher
    First, is the spring config file you have posted located at: "/WEB-INF/classes/persistence.xml" ?
    Yes

    Quote Originally Posted by Mark Fisher
    Second, can you show the key/val pair for jdbc.driverClassName in the jdbc.properties file at the root of your classpath?

    jdbc.driverClassName oracle.jdbc.driver.OracleDriver
    jdbc.url jdbc:oracle:thin:@192.168.103.85:1521:orcl
    jdbc.username xxx
    jdbc.password yyy


    I'm also digging through my 3rd party jar dependencies (I'm using Maven) to make sure my versions are in sych with Spring 2.0. I've just noticed 3 ClassNotFoundExceptions during startup for groovy.lang.GroovyObject, org.jruby.IRuby, and bsh.Interpreter, although I would hope that this would not cause standard XML based application contexts to fail.

  4. #4

    Default

    Oh, and I did try changing these property entries to key=value, I suppose that is actually the correct format.

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    try replacing that bean so that it has no id attribute, like so...
    Code:
      <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/jdbc.properties</value>
                </list>
            </property>
    </bean>
    Do you have another bean in a different bean definition file with the same name?

Posting Permissions

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