I created a spring mvc project using Spring Roo, with MySql database and Hibernate provider. The problem is that when I run it I get the following error:
java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
Even in applicationContext.xml, I see a error message that org.apache.commons.dbcp.BasicDataSource is not found
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="${database.driverClassName}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="testOnBorrow" value="true"/>
<property name="testOnReturn" value="true"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="1800000"/>
<property name="numTestsPerEvictionRun" value="3"/>
<property name="minEvictableIdleTimeMillis" value="1800000"/>
<property name="validationQuery" value="SELECT 1"/>
</bean>
But in the pom created by Spring Roo I see the dependency for commons-dbcp, which is the jar that contains the missing class:
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
and in Maven Dependencies folder, I see file commons-dbcp-1.3.jar
Does anyone know why I'm getting the error?
I changed commons-dbcp version to 1.4 and commons-pool version to 1.4 (from 1.5.6) and also removed the exclusions part form the commons-dbcp dependency and it started to work. This are de dependencies now:
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.4</version>
<!-- <version>1.5.6</version> -->
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>