-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate 2.1 + Tomcat 5 hot deploy problem
PostPosted: Mon Jun 14, 2004 6:06 pm 
Newbie

Joined: Mon Jun 14, 2004 5:35 pm
Posts: 5
Location: Michigan
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!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 6:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Try to find some info in the tomcat user list, is sounds like something wrong with the hot classloader.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 9:08 am 
Newbie

Joined: Mon Jun 14, 2004 5:35 pm
Posts: 5
Location: Michigan
Alright, thanks.[/quote]


Top
 Profile  
 
 Post subject: solved
PostPosted: Tue Jun 15, 2004 11:22 am 
Newbie

Joined: Mon Jun 14, 2004 5:35 pm
Posts: 5
Location: Michigan
In case anyone else has this problem, it can be solved by moving the Context information from within the server.xml file to CATALINA_HOME/conf/Catalina/(hostname)/(contextname).xml.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.