Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the source and put it in other packages. So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of org.apache.commons.dbcp.BasicDataSource in your source - btw why do you cast to BasicDataSource, you can use javax.sql.DataSource?
Gernot -----Ursprüngliche Nachricht----- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 17:19 An: Tomcat Users List Betreff: Re: DBCP ClassCastException Hi Lutz, I changed the Resource tag definition to: <Resource name="jdbc/myserver" auth="Container" type="javax.sql.DataSource " maxActive="100" maxIdle="30" maxWait="10000" driverClassName="com.mysql.jdbc.Driver"/> I'm setting the username/password and jdbcurl using code. I still get the same ClassCastException. Is Tomcat instantiating the correct DataSourceFactory? I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib Thanks, Dhiren On 5/8/05, Lutz Zetzsche <[EMAIL PROTECTED]> wrote: > > Hi Dhiren, > > Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: > > Hi all, > > > > I'm getting a the following ClassCastException running Tomcat 5.5.9 > > with MySQL > > > > java.lang.ClassCastException: > > org.apache.tomcat.dbcp.dbcp.BasicDataSource > > > > Here's the relevant code: > > *Java code:* > > org.apache.commons.dbcp.BasicDataSource datasource; > > > > datasource = > > (BasicDataSource)ctx.lookup("java:comp/env/jdbc/myserver"); > > > > *web.xml* > > <resource-ref> > > <description>DB Connection</description> > > <res-ref-name>jdbc/myserver</res-ref-name> > > <res-type>javax.sql.DataSource</res-type> > > <res-auth>Container</res-auth> > > </resource-ref> > > *server.xml* > > *....* > > <ResourceParams name="jdbc/myserver"> > > <parameter> > > <name>factory</name> > > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> > > </parameter> > > *...* > > > > > > This same code works in Tomcat 5.0.30. > > > > Has anything changed? Am I missing something? > > Yes. The syntax for the Resource tag in the server.xml has changed. The > resource parameters are no longer defined in tags nested into the > Resource tag, but in attributes of the tag. This is an example from the > Tomcat 5.5 documentation: > > <Resource name="jdbc/TestDB" auth="Container" > type="javax.sql.DataSource" maxActive="100" maxIdle="30" > maxWait="10000" username="javauser" password="javadude" > driverClassName="com.mysql.jdbc.Driver" > url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/> > > > http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html > > Best wishes, > > Lutz > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]