org.apache.tomcat.jdbc.pool.DataSource is no longer in the tomcat 7 dbcp jar?
Asked Answered
T

1

8

I am trying to create a spring-managed standalone pool for tomcat-dbcp using the version 7.0.30 of tomcat-dbcp.jar

However it seems the org.apache.tomcat.jdbc.DataSource class that is referred to in the Tomcat's documentation (http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#Standalone)

<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
    destroy-method="close">
    <property name="factory"
        value="org.apache.tomcat.jdbc.pool.DataSourceFactory" />
    <property name="type" value="javax.sql.DataSource" />
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/ym" />
    <property name="username" value="admin" />
    <property name="password" value="admin" />
    <property name="initialSize" value="5" />
    <property name="maxActive" value="10" />
</bean>

So this spring bean definition is correct according to Tomcat doc, however when I start the app up, I get CNF exception:

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.tomcat.jdbc.pool.DataSource] for bean with name 'dataSource' defined in class path resource [application-context.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.DataSource

Am I being super stupid and missing the obvious here???

Trypanosome answered 17/9, 2012 at 15:50 Comment(0)
S
10

Class org.apache.tomcat.jdbc.pool.DataSource is included in tomcat-jdbc.jar, not tomcat-dbcp.jar. The Tomcat JDBC Connection Pool is a replacement for commons-dbcp, of which tomcat-dbcp is just a renamed version.

The jar file tomcat-jdbc.jar is not included in all Tomcat installations (e.g. it is not included in the standard Debian/Ubuntu package). You can download it from Maven Central or you can find it in the Tomcat binary distribution archive.

Sidero answered 17/9, 2012 at 16:49 Comment(4)
It's included, at least, in 7.0.37 tar.gzQuorum
You're right, I meant that it is not included in some installations, like the Debian/Ubuntu package for Linux. Edited my answer to make it more clear.Sidero
I have windows package of tomcat. but it is tomcat 8.0.14. where should I put this jar file?Flyboat
@Flyboat It should already be included in the Windows package. Look under the lib folder.Sidero

© 2022 - 2024 — McMap. All rights reserved.