Spring MVC-Hibernate error: BasicDataSource is not found

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?

Answers


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>

Need Your Help

jQuery; click to show html content and countdown, and then additional content

php javascript jquery html

I wanted to create a link that would show content before showing a direct link on my forum.

Reading Data from CSV to Screen output

c# c++ c windows csv

This may not be allowed but I'll ask anyway.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.