using hibernate 2.0.2, tomcat 4.1.12, mysql 4.0.17
i use to have only this context configured in my tomcat server.xml file:
Code:
<Context path="/cemiterio" docBase="C:\Otavio_Augusto\transporte\projetos\cemiterios\projeto\build\cemiterio" debug="0" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_examples_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/cemiterio" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/cemiterio">
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
<parameter><name>url</name><value>jdbc:mysql://localhost/cemiterio</value></parameter>
<parameter><name>driverClassName</name><value>org.gjt.mm.mysql.Driver</value></parameter>
<parameter><name>username</name><value>user</value></parameter>
<parameter><name>password</name><value>secret</value></parameter>
<parameter><name>maxWait</name><value>5000</value></parameter>
<parameter><name>maxIdle</name><value>2</value></parameter>
<parameter><name>maxActive</name><value>5</value></parameter>
</ResourceParams>
</Context>
ok, it was fine. but now i'm developing another application, and i suppose i have to add similar lines to it, right? a new context to server.xml ...
i understand the lines above configure a data source for a connection pool. is it possible to have another connection pool for another data source? this is the new context i'm trying to add to server.xml
Code:
<Context path="/plano" docBase="C:\Otavio_Augusto\projetos\plano\projeto\build\plano"
debug="0" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_examples_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/plano" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/plano">
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
<parameter><name>url</name><value>jdbc:mysql://localhost/plano</value></parameter>
<parameter><name>driverClassName</name><value>org.gjt.mm.mysql.Driver</value></parameter>
<parameter><name>username</name><value>user</value></parameter>
<parameter><name>password</name><value>pass</value></parameter>
<parameter><name>maxWait</name><value>5000</value></parameter>
<parameter><name>maxIdle</name><value>2</value></parameter>
<parameter><name>maxActive</name><value>5</value></parameter>
</ResourceParams>
</Context>
i get the following error in tomcat's log:
Code:
2004-03-29 03:38:27 WebappLoader[/plano]: Reloading checks are enabled for this Context
2004-03-29 03:38:28 StandardManager[/plano]: Seeding random number generator class java.security.SecureRandom
2004-03-29 03:38:28 StandardManager[/plano]: Seeding of random number generator has been completed
2004-03-29 03:38:29 StandardContext[/plano]: Exception sending context initialized event to listener instance of class struts.PlanoContextListener
java.lang.NoClassDefFoundError
at struts.PlanoContextListener.contextInitialized(Unknown Source)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3250)
let me explain: in PlanoContextListener, i try to get a connection from the pool (teh same way i do in the other application i mentioned...nothing weird) inside the contextInitialized method. i have a singleton class that does it for me, called HibernateUtil. so, i just do
Code:
Session session = HibernateUtil.currentSession();
and at this point the app crashes, and only the other contexts keep working.
this is the HibernateUtil class i mentioned:
Code:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (HibernateException ex) {
throw new RuntimeException("Exception building SessionFactory: " + ex.getMessage(), ex);
}
}
public static final ThreadLocal session = new ThreadLocal();
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}
}
Any help?
thanks for reading this.