junit problem with commons dbcp
When I run my junit test against my DAOs, I get a weird Commons DBCP Exception complaining about the initialiSize for the data source could not be set.
however, when I run the app from tomcat, the data source loads fine.
here's the stack trace
Code:
junit.framework.AssertionFailedError: Exception in constructor: testGetCampaign (org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'realDataSource' defined in class path resource [web/WEB-INF/dataAccessContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'initialSize' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'initialSize' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'initialSize' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'initialSize' 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:796)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:716)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:844)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:871)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:860)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:926)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:727)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:336)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
....
Also here's my dataAccess.xml
Code:
<bean id="realDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${emod.jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${emod.jdbc.url}</value>
</property>
<property name="username">
<value>${emod.jdbc.username}</value>
</property>
<property name="password">
<value>${emod.jdbc.password}</value>
</property>
<!--
- The initial number of connections that are created when the pool is started.
-->
<property name="initialSize">
<value>${emod.jdbc.datasource.initialSize}</value>
</property>
<!--
- The maximum number of active connections that can be allocated from
- this pool at the same time, or zero for no limit.
-->
<property name="maxActive">
<value>${emod.jdbc.datasource.maxActive}</value>
</property>
<!--
- The maximum number of active connections that can remain idle in the
- pool, without extra ones being released, or zero for no limit.
-->
<property name="maxIdle">
<value>${emod.jdbc.datasource.maxIdle}</value>
</property>
<!--
- The maximum number of milliseconds that the pool will wait
- (when there are no available connections) for a connection to be
- returned before throwing an exception, or -1 to wait indefinitely.
-->
<property name="maxWait">
<value>${emod.jdbc.datasource.maxWait}</value>
</property>
<!--
- Enable prepared statement pooling for this pool. Default is false
-->
<property name="poolPreparedStatements">
<value>${emod.jdbc.datasource.poolPreparedStatements}</value>
</property>
</bean>
the junit and tomcat app both read this same file, yet in the junit case it throws that above exception.. any ideas why?
thanks