Here's the exception I get with the tomcat_dbcp.jar file in lib: java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource cannot be cast to org.apache.commons.dbcp.BasicDataSource
When I remove the tomcat_dbcp.jar file from lib, I get this exception: javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory Why is it looking for org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory? i would expect it to try and instantiate the BasicDataSourceFactory in the commons dbcp package. Am I missing something? I don't want to use the org.apache.tomcat.dbcp.dbcp.BasicDataSource class in my code because I need my application to be independent of the server. We're using eclipse to develop, which uses an embedded jetty, so i won't be able to run this code while debugging in eclipse. Here's what the code looks like: import org.apache.commons.dbcp.BasicDataSource; private static BasicDataSource ds = null; Properties dbProps = new Properties(); dbProps.load(new FileInputStream(dbConfFilePath)); ds = (BasicDataSource) ctx.lookup("java:comp/env/" + dbProps.getProperty(RESOURCE_NAME_KEY)); ds.setDriverClassName(dbProps.getProperty(DRIVER_KEY)); ds.setUrl(getJdbcUrl(dbProps)); ds.setUsername(dbProps.getProperty(USERNAME_KEY)); ds.setPassword(dbProps.getProperty(PASSWORD_KEY)); Thanks! On Tue, Mar 9, 2010 at 10:16 AM, Propes, Barry L <barry.l.pro...@citi.com>wrote: > I was initially getting this error, too, with my first install, but rebuilt > the Tomcat collection and finally vanquished it using the factory reference > of org.apache.tomcat.dbcp.DataSourceConnectionFactory in there, even though > I'd initially gotten an error not being able to create the factory resource. > > Now I'm only getting a naming context error. If I get that fixed, I'll be > on my way. > > > > -----Original Message----- > From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] > Sent: Tuesday, March 09, 2010 11:38 AM > To: Tomcat Users List > Subject: Re: Commons DBCP in Tomcat 6.x > > 2010/3/9 Dhiren Bhatia <dhiren.for...@gmail.com>: > > Hi, > > > > I'm trying to use the commons DBCP package with Tomcat 6.x. I know > > that the tomcat_dbcp.jar has the commons files renamed, however I > > would prefer to use the commons jar files so I can use the class > > org.apache.commons.dbcp.BasicDataSource in my code. > > > > To do this, I deleted the tomcat_dbcp.jar file from CATALINA_HOME/lib > > and replaced it with the commons jar file. I assumed that the class > > loader would pick it up like it did in the earlier version of tomcat > > but that doesn't seem to happen. I still get an ClassCastException > > since tomcat tries to cast the org.apache.commons.dbcp.BasicDataSource > > to org.apache.tomcat.dbcp.dbcp.BasicDataSource. > > > > Is there any way I can force Tomcat 6.x to load my commons dbcp jar > > instead of the tomcat_dbcp.jar which comes with the distro? > > > > 1. How is your <Resource> is defined. Please show us (remove any > passwords). > Note, that you have to specify className="..." explicitly. > > 2. What, exactly, stack trace you are getting? > > Best regards, > Konstantin Kolinko > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >