Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3
Mapping documents:
None
Code between sessionFactory.openSession() and session.close():
None. But we are doing:
Configuration c = new Configuration();
c.addFile(fileName);
SessionFactory factory = c.configure().buildSessionFactory();
and it blows up because it can't find the cfg file. I promise, it is where fileName says it is.
But it looks like the Hibernate source code ignores the setting. When you call configure, this is the method
Code:
public Configuration configure() throws HibernateException {
configure( "/hibernate.cfg.xml" );
return this;
}
which doesn't look like it's paying any attention to the files a calling class might add.
Am I misunderstanding/reading?
What I need to do is give Hibernate cfg file that's not in the application's path.
Thanks
Full stack trace of any exception that occurs:Code:
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1137)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1161)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1148)
at com.rps.hibernate.CFHelper.main(CFHelper.java:58)
Name and version of the database you are using:The generated SQL (show_sql=true):Debug level Hibernate log excerpt:Code:
About to addFile C:\JRun4\servers\default\cfusion-ear\cfusion-war\hibernate\hibernate.cfg.xml to the configuration.
- Mapping file: C:\JRun4\servers\default\cfusion-ear\cfusion-war\hibernate\hibernate.cfg.xml
Added file C:\JRun4\servers\default\cfusion-ear\cfusion-war\hibernate\hibernate.cfg.xml to the configuration.
- configuring from resource: /hibernate.cfg.xml
- Configuration resource: /hibernate.cfg.xml
- /hibernate.cfg.xml not found
[/code]