- This topic has 4 replies, 3 voices, and was last updated 19 years, 10 months ago by dhonig.
-
AuthorPosts
-
Stephen McConnellMemberI am trying to set up a project and Add Hibernate Capablities to my project. The “wizzard” only lets me put the hibernate.cfg.xml file in the “src” directory.
I am trying to put in under the “WEB-INF” directory with the other struts-conf.xml file and several other configuration files. I browse to the “/WebRoot/WEB-INF” folder and select it and receive a “the specified path does not exist in this workspace.” But that path most certainly does exist….
I can change it my manually moving the hibernate.cfg.xml file to that workspace, but I haven’t tried updating it through XDoclet, yet. So, I don’t know the ramifications of that.
Since the “src” folder is not going to be deployed to the server… Why does MyEclipse force me to put the hibernate.cfg.xml file there. Specifications state it has to be in my classpath… What gives?
Riyad KallaMemberThe file is suppose to go into the root of your /src dir, while /src is not deployed, everything in it is built/copied out to WEB-INF/classes which IS deployed. Hibernate needs the cfg.xml file in the classpath of your project to load its config settings, your WEB-INF dir is not in your classpath, so if you were to put it there, you’d be ‘hiding’ it from Hibernate and it wouldn’t work.
Stephen McConnellMemberActually if the config file is not in the class path, you can pass the info to it at initialization time…. Directly from “Hibernate In Action” …
SessionFactory sessions = new Configuration().configure("/WEB-INF/hibernate.cfg.xml").buildSessionFactory();
I’ve tried this and it works….
I try to keep all my configuration files together, it makes for easier maintenance, documentation and version control (if you keep configuration files in version control).
Stephen McConnell
Riyad KallaMemberI stand corrected, thx for the info!
dhonigMember❓
Just to clarify…I don’t have hibernate in action available, so I am guessing you are setting the config from inside a servlet and that just happens to work from inside a servlet with the web container your using or are there some other details you could provide that explain why this works?…..
In JBoss the classloader does not recognize that….You would have to do a bit of monkeying around, but I am guessing it might work from a servlet class that is specified in web.xml….?
-
AuthorPosts