J
jstorta
I am new to Hibernate. I've installed v3.2.5 and have been going
through the Introduction to Hibernate documentation at hibernate.org.
I am running on Tomcat v6.0.14
Everything is working great except for one thing. I cannot get
Hibernate to find and use the hibernate.cfg.xml file.
If I place the hibernate.cfg.xml file in my WEB-INF/classes directory,
I get the following message in the Tomcat log when I run my test.
21:22:33,298 INFO Environment:547 - hibernate.properties not found
The message did not really concern me since I was not using a
hibernate.properties file. However, my test then fails with the
following exception.
Exception: org.hibernate.HibernateException: Hibernate Dialect must be
explicitly set
The Dialect, and all of the other JDBC parameters are in the
hibernate.cfg.xml so it seems it is just not finding the config file
and is only looking for the hibernate.properties file.
If I create a hibernate.properties file and place it in the same
directory as the hibernate.cfg.xml file, everything works fine.
# ls -al WEB-INF/classes/hibernate*
-rw-rw-r-- 1 webuser webgrp 1463 2008-01-02 21:40 WEB-INF/classes/
hibernate.cfg.xml
-rw-rw-r-- 1 webuser webgrp 14782 2008-01-02 21:40 WEB-INF/classes/
hibernate.properties
The contents of my hibernate.cfg.xml file is listed below in case it
helps.
Any guidance would be appreciated.
Thanks.
### hibernate.cfg.xml #####
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-
configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property
name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/devdb</
property>
<property name="connection.username">dbuser</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</
property>
<!-- Enable Hibernate's automatic session context management -- <property name="current_session_context_class">thread</
property>
<!-- Disable the second-level cache -->
<property
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</
property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="Project.hbm.xml"/>
</session-factory>
</hibernate-configuration>
through the Introduction to Hibernate documentation at hibernate.org.
I am running on Tomcat v6.0.14
Everything is working great except for one thing. I cannot get
Hibernate to find and use the hibernate.cfg.xml file.
If I place the hibernate.cfg.xml file in my WEB-INF/classes directory,
I get the following message in the Tomcat log when I run my test.
21:22:33,298 INFO Environment:547 - hibernate.properties not found
The message did not really concern me since I was not using a
hibernate.properties file. However, my test then fails with the
following exception.
Exception: org.hibernate.HibernateException: Hibernate Dialect must be
explicitly set
The Dialect, and all of the other JDBC parameters are in the
hibernate.cfg.xml so it seems it is just not finding the config file
and is only looking for the hibernate.properties file.
If I create a hibernate.properties file and place it in the same
directory as the hibernate.cfg.xml file, everything works fine.
# ls -al WEB-INF/classes/hibernate*
-rw-rw-r-- 1 webuser webgrp 1463 2008-01-02 21:40 WEB-INF/classes/
hibernate.cfg.xml
-rw-rw-r-- 1 webuser webgrp 14782 2008-01-02 21:40 WEB-INF/classes/
hibernate.properties
The contents of my hibernate.cfg.xml file is listed below in case it
helps.
Any guidance would be appreciated.
Thanks.
### hibernate.cfg.xml #####
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-
configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property
name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/devdb</
property>
<property name="connection.username">dbuser</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</
property>
<!-- Enable Hibernate's automatic session context management -- <property name="current_session_context_class">thread</
property>
<!-- Disable the second-level cache -->
<property
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</
property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="Project.hbm.xml"/>
</session-factory>
</hibernate-configuration>