Forums Register Login

hibernate.cfg.xml not found

+Pie Number of slices to send: Send
I just created a struts project (in eclipse), created a bean "User" and two mapping files namely hibernate.cfg.xml and user.hbm.xml. I get

hibernate.cfg.xml not found error

on hitting the action where i have session/transaction statements. Any idea where should i dump it so that it is accessible, i tried moving it from web-inf to web-inf/lib. both dont seem to work.
+Pie Number of slices to send: Send
hibernate.cgf.xml needs to be at the root of your application's classpath if you are using the default configuration mechanism.
+Pie Number of slices to send: Send
 

Originally posted by Paul Sturrock:
hibernate.cgf.xml needs to be at the root of your application's classpath if you are using the default configuration mechanism.



It still did not work for me. Do I have a choice like property/config file where i can override the default configurations? what does it take to convert a simple web/java project into hibernate, other than having hibernate-jar to be in lib/classpath of the application. Currently my web.xml has no entries on on hbm/xml files.
+Pie Number of slices to send: Send
 


It still did not work for me. Do I have a choice like property/config file where i can override the default configurations?


You can programatically override your configuration. See the JavaDocs for the Configuration class to see how.


what does it take to convert a simple web/java project into hibernate, other than having hibernate-jar to be in lib/classpath of the application.


Assuming you have hibernate.jar and all its dependencies in the class path it will work.


Currently my web.xml has no entries on on hbm/xml files.


It doesn't need any. Have you been through the quickstart?
+Pie Number of slices to send: Send
Thanks Paul. I left eclipse and came down to Textpad and ant. You were right, I simply had to dump the two xmls into classpath. That problem is solved, and it was not just hibernate-3.2.6.ga.jar there were other jars apart from apache-commons that i had to bring in, like cglib and asm I dont know what they do, but I feel I can still go ahead keeping the abstractions as is. My Hello world is still few steps away, (some jndi configurations to be looked into) but i think it will go smooth here after. Thank you very much again.
+Pie Number of slices to send: Send
I only had to put hibernate.cfg.xml directly under my "src" folder in eclipse.
+Pie Number of slices to send: Send
 

Originally posted by Timothy Sam:
I only had to put hibernate.cfg.xml directly under my "src" folder in eclipse.



This is because by default in eclipse everything that is in your build path is also on your runtime classpath. This is not the case with JEE applications.
+Pie Number of slices to send: Send
Yes Timothy it works that way as well. I tried to save an object from session to the db and it has successfully inserted it, will explore more of it. Thanks.
+Pie Number of slices to send: Send
Try putting hibernate.cfg.xml under WEB-INF/classes/
[ December 09, 2008: Message edited by: Dan La ]
+Pie Number of slices to send: Send
 

Originally posted by Dan La:
Try putting hibernate.cfg.xml under WEB-INF/classes/

[ December 09, 2008: Message edited by: Dan La ]



The ant script does the same anyways.

Eclipse doesn't show me 'classes' folder(may be i will have to configure some perspectives or so). But i do hope it would be fine if I manually dump them on the app deployed on the server.
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3626 times.
Similar Threads
Hibernate - Can't delete from database!
Hard to configurate Hibernate using NetBeans 5.5.1
Eclipse ganymede using Struts
Classloader problem?
Eclipse ganymede Does it support struts 1.1
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:13:01.