Here's a link from the Tomcat Wiki. http://wiki.apache.org/tomcat/TomcatHibernate
The bottom portion of the document explains how to use Hibernate to manage database pooling instead of Tomcat. I hope it gives you some leads. . . . . just my two cents /mde --- On Thu, 5/13/10, Jeff Hubbs <jhubbsl...@att.net> wrote: > From: Jeff Hubbs <jhubbsl...@att.net> > Subject: Porting app from Tomcat 5.0.28 to 6.0.26 > To: "Tomcat Users List" <users@tomcat.apache.org> > Date: Thursday, May 13, 2010, 12:55 PM > Hello - > > I have a DB2-backed legacy app on a legacy platform that > I'm trying to modernize. My objective is to modernize > the platform underneath the app (Gentoo Linux for now, > Tomcat 6.0.26, Sun JDK 1.6.0.20) and do so in a way that a > longtime Java/Tomcat integrator would readily recognize (I'm > not one). App uses Hibernate and c3p0; Hibernate is > packaged in the app's war but c3p0 is not; I've installed > c3p0 through Gentoo's usual package management system. > I've also brought in the jar for the proper version of IBM > DB2 JDBC driver and its corresponding "license jar" to match > the DB2 instance version (versioning between DB2 and JDBC > driver are tightly coupled). > > On the legacy Tomcat 5.0 / JDK 1.5 platform, the database > connection configuration info is handled in a seemingly > customized way - something to do with virtual hosts. > At the top of the Tomcat-instance-wide server.xml file is > this structure: > > <!DOCTYPE web-app[ > <!ENTITY vhosts SYSTEM "vhosts.xml"> > ]> > > But for now, I'm not interested in dealing with any kind of > virtual host arrangement. The impetus behind that was > so that users can run two independent sessions of the app in > two separate browser tabs or windows . > > In the vhosts.xml file is info that looks like it ought to > belong in the app's context.xml file. I understand > that how context sections are written have changed since 5.0 > and I *think* I've got that worked out. > > The app's original MANIFEST.MF file has this in it: > > Classpath: > WEB-INF/classes/mycapp/resource > WEB-INF/classes/myapp/resource > /tld > WEB-INF/classes/elms/resource/hbm/MYAPP > > So: given a working platform and after deploying the > app war that I've been given (let's call it "myapp.war"), > here are the post-deploy steps I've worked out so far: > > * Create a symlink for > $CATALINA_BASE/webapps/myapp/WEB-INF/lib/c3p0.jar to where > the package manager has put c3p0.jar > > * Create symlinks for db2jcc.jar and db2jcc_license_cu.jar > in $CATALINA_BASE/webapps/myapp/WEB-INF/lib to where I've > put them under /usr/src > > * Generate a new > $CATALINA_BASE/webapps/myapp/META-INF/context.xml (see > below) and symlink > $CATALINA_BASE/conf/Catalina/localhost/myapp.xml to it > > * Add the following to > $CATALINA_BASE/webapps/myapp/WEB-INF/web.xml, before the > closing "</web-app>": > > <resource-ref> > <description>DB connection pool for > MYAPP</description> > <res-ref-name>jdbc/myappqa</res-ref-name> > <res-type>com.mchange.v2.c3p0.ComboPooledDataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > > I've created a context.xml that looks like: > > <Context > docBase="${catalina.home}/webapps/myapp" path="" > reloadable="false"> > <Resource name="jdbc/myappqa" > description = > "MYAPP connection pool" > auth="Container" > > type="com.mchange.v2.c3p0.ComboPooledDataSource" > > username="myappuser" > > password="myapppassword" > > driverClass="com.ibm.db2.jcc.DB2Driver" > > url="jdbc:db2://mydb2server:50000/TESTDATA" > > factory="org.apache.naming.factory.BeanFactory" > minPoolSize="15" > . > . <scissors of > brevity applied - more parameters set> > . > /> > </Context> > > > I've been able to browse to the app and get a login page, > but things explode at login attempt, i.e., first attempt to > access the data source. > > Question 1: For this to work, do I need to add > "WEB-INF/lib" to the "Classpath:" list? There are > about 80 jar files (including log4j, ftpbean, Hibernate) in > there aside from the symlinks I've added for the c3p0, JDBC > driver, and license jar files. > > Question 2: In my context.xml, is that one parameter > supposed to be "driverClass" or "driverClassName"? > I've seen both used seemingly for the same purpose. > > Question 3: Some customization has been done > involving hibernate.properties which I don't think is > necessarily causing a problem (its "meat" has been replaced > by a reference to another file much like server.xml), but in > there I've noticed this: > > <property > name="hibernate.connection.pool_size">15</property> > > As I understand it, setting this parameter activates > Hibernate's own connection pooler and further that > Hibernate's own connection pooler is not supposed to be used > in any capacity other than learning and testing. Does > having this setting be in here mean that this app was built > (intentionally or not - likely not) to use Hibernate's > connection pooler and c3p0 end-to-end? > > Thanks in advance for your opinions/assistance. > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org