Hi everyone,
I'm having some trouble with configurating Hibernate with NetBeans 5.5.1.
I'm using Hibernate 3.0,
MySQL-5.0.51a
and Sun Java System Application Server 9.1.
I want to use the hibernate.cfg.xml file, which I've written with the help of some tutorials and the "Hibernate in Action" book, but I always get this error when trying to run the application in NetBeans:
"Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found"
I've tried to use a static util class for creating
one Hibernate session and one Transaction and saving them in ThreadLocal objects (like in "Hibernate In Action", chapter 8) but since the hibernate.cfg.xml can't be found, that class can't be initialized and Hibernate can't be started.
I've read about other people with this problem but I haven't seen any good solution to it.
Currently I have Hibernate in the EJB module of an Enterprise Application (Maybe that's a bad idea. I don't know.) and I've tried moving the cfg.xml file around from the src\conf folder of the module to directly under src, directly under the src folder of the application and even to WEB-INF.
In those cases I've set the path to the file as argument to the configure method, (/WEB-INF/hibernate.cfg.xml in that case and the full physical file path in the other cases since I don't know the logical path), but that didn't help.
An example:
Code:
sessionFactory = new Configuration()
.configure("C:\\Exjobb Ylva D\\Extract to cv 2\\Extract to cv 2-ejb\\src\\hibernate.cfg.xml")
.buildSessionFactory();
I also read that the cfg.xml file needs to be put in the class-path and that I have to make sure it gets copied to the build folder of the application but I don't know how to do that.(Changing some Ant script? But how?)
Is that what I need to do to make it work?
In that case, I need to know what files I need to change and how to write the code for that. My problem is that I know Java and writing source code but I don't know much about the internal workings of NetBeans and of how to configure everything I need for the project.
I'd be Very grateful for any kind of help on this matter. -If it's tips on actual coding or links to tutorials doesn't matter. I have read a lot and searched a lot on the Internet already and will continue to do so but since I Really need to finish this project
soon I think I need some help from other people as well. (By the way: Using another IDE than NetBeans 5.5.1 is not an option. This is a part of my thesis and I can't make such a change right now.)
Hoping to get some answers!
Thanks in advance,
Ylva