I have Tomcat 5.018 and mysql 11.18 and have successful jdbc access (jsp's accessing java classes which have the jdbc code).
I would like to migrate to persistent java beans using hibernate (
www.hibernate.org).
I have successfully installed hibernate 2.1.2 and created persistent objects in a standalone program.
When I attempt to do so in a servlet under tomcat, this line:
sessionFactory = new Configuration().configure().buildSessionFactory();
throws a HibernateException, "/hibernate.cfg.xml not found".
In my WEB-INF/classes folder, I have:
-HibernateUtil.java/class (containing the above line, pasted from the hibernate docs)
-hibernate.cfg.xml (the file it cannot find)
-Member.java/class (an ordinary javabean)
-Member.hbm.xml (the mapping file to my table for the above javabean)
-Membership.java/class (the servlet calling the method containing the offending line)
for your pleasure, here is my hibernate.cfg.xml:
----
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/Membership</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- Mapping files -->
<mapping resource="Member.hbm.xml"/>
</session-factory>
</hibernate-configuration>
----
the offending lines in HibernateUtil.java:
----
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (HibernateException ex) {
throw new RuntimeException("Exception building SessionFactory: " + x.getMessage(), ex);
}
----
'Sorry to ask what may be a n00b question (ok, I *did* pick the beginner forum ;-), but I've googled and searched and run out of places to look. Or think I have...
Is their some simple common cockpit error everybody but me knows about that would cause this?
Thanks!
Mark
the log entry:
2004-04-01 23:20:26 StandardWrapperValve[invoker]: Servlet.service()
for servlet invoker threw exception
java.lang.RuntimeException: Exception building SessionFactory:
/hibernate.cfg.xml not found
at HibernateUtil.<init>(HibernateUtil.java:21)
at Membership.processRequest(Membership.java:42)
at Membership.doGet(Membership.java:81)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:466)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)
Caused by: net.sf.hibernate.HibernateException: /hibernate.cfg.xml not
found
at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:831)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:855)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:842)
at HibernateUtil.<init>(HibernateUtil.java:19)
... 32 more