I am trying to create two PropertyPlaceholderConfigurer's, one for accessing property files and the other for accessing the database... the code is as follows
<bean id="otherPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="properties">
<bean class="org.apache.commons.configuration.ConfigurationConverter" factory-method="getProperties">
<constructor-arg>
<bean class="org.apache.commons.configuration.DatabaseConfiguration">
<constructor-arg ref="myDataSource"/>
<constructor-arg value="dbo.APPLICATIONPROPERTIES"/>
<constructor-arg value="NAME"/>
<constructor-arg value="VALUE"/>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="propertyConfigurer" class="com.fexco.wuams.util.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:database.properties</value>
</list>
</property>
</bean>
I have the following ComboPooledDataSource bean
<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${driver}"/>
<property name="jdbcUrl" value="${url}"/>
<property name="user" value="${username}"/>
<property name="password" value="${password}"/>
<property name="initialPoolSize" value="5"/>
<property name="minPoolSize" value="5"/>
<property name="maxPoolSize" value="5"/>
<property name="maxIdleTime" value="1200"/>
<property name="idleConnectionTestPeriod" value="300"/>
</bean>
which works perfectly for the rest of my application except when i try use it for my bean id="otherPropertyConfigurer"... i get the following error
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClass' threw exception; nested exception is java.beans.PropertyVetoException: Could not locate driver class with name '${jdbc.driverClassName}'.
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1275)
... 72 more
if i hardcode the database variables in ComboPooledDataSource (e.g. change ${jdbc.driverClassName} to net.sourceforge.jtds.jdbc.Driver everything works fine but for some reason when i add the otherPropertyConfigurer, my original propertyConfigurer does not work
Does anyone have any ideas on how to resolve this?
Aucun commentaire:
Enregistrer un commentaire