#46 Invalid property 'username' of bean class [com.mtgi.analytic

open
nobody
None
5
2010-07-29
2010-07-29
Karl Palsson
No

Although the tutorial says that it should work with any javax.sql.DataSource, it doesn't work for me with a DBCP BasicDataSource.

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'username' of bean class [com.mtgi.analytics.aop.config.v11.BtDataSourceBeanDefinitionDecorator$DataSourceFactory]: Bean property 'username' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1012)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:860)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341)
... 77 more

My bean config is

<bean id="nipDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
bt:tracking-manager="defaultTrackingManager">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="MUST BE OVERRIDDED IN APPLICATION.XXXX.PROPERTIES FILES!"/>
<property name="username" value="someUser"/>
<property name="password" value="somePassword"/>
<property name="logAbandoned" value="true"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="600"/>
<property name="maxActive" value="25"/>
<property name="validationQuery" value="select 1 from dual"/>
<property name="testOnBorrow" value="true"/>
</bean>

That worked just fine without the bt:tracking-manager attribute. I've tried with both defaultTrackingManager and with a named manager.

I guess I should say, this is with spring 3.

Discussion