-->
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.  [ 3 posts ] 
Author Message
 Post subject: "/hibernate.cfg.xml not found" from a Tomcat servl
PostPosted: Fri Apr 02, 2004 2:36 am 
Newbie

Joined: Wed Mar 31, 2004 6:46 pm
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 1:34 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Try to make the quickstart sample work, you'll find your issue that way.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 7:19 pm 
Newbie

Joined: Wed Mar 31, 2004 6:46 pm
Posts: 2
emmanuel wrote:
Try to make the quickstart sample work, you'll find your issue that way.


Thanks so much for replying: 'Turns out I had the exact same problem there, and it fell into the "if it was a snake, it woulda bit me" category: I had put the jar files that belong in the context classpath in the global classpath... This particular issue was because hibernate.jar was not in WEB-INF/lib or WEB-INF/classes, but that tutorial promised me a world of probs with the others as well...

Mark


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.