stu_zamani wrote:
hi...
i write a web application that use hibernate .
in code i write
Configuration cfg = new Configuration();
sessionFactory = cfg.configure().buildSessionFactory();
but throw Exception that hibernate.cfg.xml not found .
where is this file.
thanks
How are you deploying with TOMCAT ? If you are working in a raw enviroment with in unpacked WAR then "WEB-INF/classes/hibernate.cfg.xml" should work for you, this may become a full system pathname like this /opt/jakarta-tomcat-5.5.9/webapps/your-context/WEB-INF/classes/hibernate.cfg.xml
If you are working through an IDE (Eclipse,Intelij) that auto-deploys your web-app then you should generally create the file hibernate.cfg.xml at the toplevel directory if your source tree.
An example file for hibernate 3.0.5 might look like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- <property name="connection.datasource">java:comp/env/jdbc/tomcat_test</property> -->
<!-- Mapping files -->
<!-- <mapping resource="com/domain/empty.hbm.xml"/> -->
</session-factory>
</hibernate-configuration>