Hello,
I have Hibernate 2.1 set up with Tomcat 5.0.25. If I deploy my application and completely restart tomcat everything works great. However, if I try to redeploy it (by touching the .war file or using the tomcat manager), I can no longer connect to the database. In the logs it looks like it can't find the configuration or something. Completely restarting tomcat always fixes the problem (but I would like to avoid this). I am using the ThreadLocal pattern copied exactly from the quickstart example in the docs.
Some files and other info (anything in parentheses was edited out):
This is within my Context config in server.xml:
Code:
<Resource name="jdbc/(DBName)" scope="Shareable" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/(DBName)">
<parameter>
<name>factory</name>
<value>
org.apache.commons.dbcp.BasicDataSourceFactory
</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/(DBname)</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>(username)</value>
</parameter>
<parameter>
<name>password</name>
<value>(password)</value>
</parameter>
</ResourceParams>
My hibernate config file:
Code:
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">
java:comp/env/jdbc/(DBName)
</property>
<property name="show_sql">
false
</property>
<property name="dialect">
net.sf.hibernate.dialect.MySQLDialect
</property>
</session-factory>
</hibernate-configuration>
From web.xml:
Code:
<resource-ref>
<description>
Connection to local mysql database.
</description>
<res-ref-name>
jdbc/(Dbname)
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>
And a stack trace of when I try to hot-deploy:
Code:
2004-06-14 15:55:40 StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
net.sf.hibernate.JDBCException: Cannot open connection
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:281)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3297)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3277)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2220)
...
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause: No suitable driver
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:750)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
... 38 more
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
... 41 more
Any help at all would be greatly appreciated!