Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

Hibernate cannot find hibernate.cfg.xml

Thread view: 
jstorta - 03 Jan 2008 03:11 GMT
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>
banyvelu@gmail.com - 19 Jan 2008 13:45 GMT
> I am new to Hibernate.  I've installed v3.2.5 and have been going
> through the Introduction to Hibernate documentation at hibernate.org.
[quoted text clipped - 80 lines]
>
> </hibernate-configuration>

can u just post the actual class implementation


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.