Abidi
Abidi

Reputation: 7996

JDBC DataSource

When I run the following code on one machine I get tomcat implementation of org.apache.tomcat.dbcp.dbcp.BasicDataSource and when I run it on another machine I get apache commons implementations of org.apache.commons.dbcp.BasicDataSource (which obviously results in ClassCastException). Just wondering why no change in code and context.xml would result in returning two different implementations of DataSource?

Context context = (Context) initialContext.lookup("java:/comp/env");
return (DataSource) context.lookup("jdbc/dbName");

Upvotes: 2

Views: 1043

Answers (1)

Chochos
Chochos

Reputation: 5159

I suppose you are not including DBCP inside your war. So it's using whatever DataSource is configured in Tomcat. You're probably using two different versions of Tomcat, or at least they have been configured differently; one must have commons-dbcp.jar and the other one has tomcat-dbcp.jar.

Upvotes: 1

Related Questions