Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Hibernate cannot find hibernate.cfg.xml

Reply
Thread Tools

Hibernate cannot find hibernate.cfg.xml

 
 
jstorta
Guest
Posts: n/a
 
      01-03-2008
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.Driv er</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.No CacheProvider</
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>
 
Reply With Quote
 
 
 
 
banyvelu@gmail.com
Guest
Posts: n/a
 
      01-19-2008
On Jan 3, 8:11 am, jstorta <(E-Mail Removed)> wrote:
> 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.Driv er</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.No CacheProvider</
> 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>


can u just post the actual class implementation
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hibernate LazyInitializationException in web application Struts asMVC, Spring as IOC and Hibernate as ORM layer Amit Jain Java 7 04-27-2009 10:27 AM
HIBERNATE - java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration Eleanna Skouta Java 2 12-09-2008 02:09 AM
Standby or Hibernate cannot be adjusted Evan Platt Computer Support 5 01-23-2007 09:47 AM
Hibernate Syncronizer now generates code for Hibernate 3.0 msenin@covad.net Java 0 07-14-2005 05:47 AM
[HIBERNATE] [EVALUATION] - Gavin King Censors Hibernate Forum Ilias Lazaridis Java 0 12-27-2004 04:26 AM



Advertisments