-->
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.  [ 1 post ] 
Author Message
 Post subject: Trouble with Tomcat DBCP/MySql
PostPosted: Mon Jun 13, 2005 1:13 pm 
Newbie

Joined: Fri May 27, 2005 7:37 am
Posts: 6
I have been working towards a connection pool with hibernate and mySql in Tomcat. I have been able to create a Tomcat cpool but was unable to do the same with hibernate. After going through all the forums and tutorials I tried the various workarounds to the session binding problem but no success so far. I am now wondeing if I have my basic settings right - and am trying to first get to hibernate without using the pool...

Hibernate version: 3

Tomcat version: 5.5.7

Tomcat config documents:
These settings got the Tomcat connection pool going...
Nothing new in server.xml.
In Tomcat/conf/Catalina/localhost/Episode:

<?xml version='1.0' encoding='utf-8'?>

<Context path="/Episode" docBase="Z:\Java\Eclipse\Episode" workDir="Z:\Java\Eclipse\Episode\work" debug="5" reloadable="true" crossContext="true">
<Resource
name="jdbc/episodeDB"
type="javax.sql.DataSource"
auth="Container"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root"
password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/academy?relaxAutoCommit=true"</value>

/>
</Context>

Mapping documents:
hibernate.cfg.xml in <apphome>/WEB-INF/classes

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<session-factory>
<!-- properties -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.datasource">java:comp/env/jdbc/episodeDB</property >
<property name="show_sql">false</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/episode</property>
<property name="connection.username">root</property>
<property name="connection.password">password</property>


<!-- mapping files -->
<mapping resource="Network.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():

transaction = session.beginTransaction();

Query query = session.createQuery("select from Network");
for (Iterator iter = query.iterate(); iter.hasNext();) {
Network network = (Network) iter.next();
out.println("Network: " + network.getId() + " : " + network.getName() + "<BR>");
}

transaction.commit();

Full stack trace of any exception that occurs:

13-Jun-2005 18:12:57 org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet testServlet as unavailable
13-Jun-2005 18:12:57 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet testServlet
javax.servlet.ServletException: Error instantiating servlet class servlet.TestServlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1034)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:725)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:131)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

Name and version of the database you are using:
mySql 4.1

My servletName definitely maps correctly to my servletClass in web.xml. Any help with this single connection problem, or a pointer to how I can get the pool going would be greatly appreciated. Thanks.


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

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.