java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool DataSourceFactory

eze picture eze · Apr 20, 2011 · Viewed 31.2k times · Source

I'm investigating moving away from an Oracle connection pool and using the Tomcat connection pool. I followed the myriad of example for configuring the <Resource> in Tomcat's /conf/server.xml. I found great info here. However, when I start Tomcat, I get the following error:

javax.naming.NamingException: Could not load resource factory class [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool DataSourceFactory]

I'm using Tomcat 6.0. My <Resource> config in /conf/server.xml is:

<Resource 
    name="jdbc/myds"
    type="javax.sql.DataSource"
    auth="Container" 
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    driverClassName="oracle.jdbc.OracleDriver"
    url="jdbc:oracle:thin:@10.10.10.33:1234:myds"
    user="myuname"
    password="mypasswd"
/>

I understand that Tomcat can't find the factory class, but I don't understand why? I don't see anything in the documentation about adding extra .jar files. I've looked in the distribution and can't find the golden .jar anyway.

Can anyone tell me what I am doing wrong?

Answer

BalusC picture BalusC · Apr 20, 2011

The Tomcat JDBC pool was introduced in Tomcat 7.0.19, yet you're attempting to use it in Tomcat 6.0 without any further configuration.

For Tomcat 6.0 you need to manually download and drop the latest release of the tomcat-jdbc.jar file in /lib folder of the Tomcat installation.