These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]

Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: hibernate.cfg.xml not found
PostPosted: Sat Jun 09, 2007 12:57 pm 

Joined: Sat Jun 09, 2007 12:36 am
Posts: 6
I have been trying to go complete my first Hibernate tutorials using eclipse and connecting to an Oracle Database.

Using Hibernate tools I have created the console configuration, the hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">XXXXXXXX</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@abcdev.iers.dta.stiop.mi.ui:1561:erddev2</property>
<property name="hibernate.connection.username">USER001</property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

The POJO file and the XML mapping document for the table I want to read was also successfully created using Hibernate tools. I also created a class to loop through the Business table and send the Business names to the console. The code is provided below:

package gov.mt.dli.erd.clm;

import java.util.Iterator;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class FirstExample
public static void main(String[] args)
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
//session = InitSessionFactory.getInstance().getCurrentSession();

Transaction tx = session.beginTransaction();

List result = session.createQuery("from Business").list();
Iterator iter = result.iterator();
while (iter.hasNext())
Business aBusiness = (Business)iter.next();
System.out.println("Name: " +

When I try to run it I get the following error messages sent to the eclipse console:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1329)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1351)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1338)
at gov.mt.dli.erd.clm.FirstExample.main(FirstExample.java:15)

The searches I have done on this error tell me my hibernate.cfg.xml file needs to be in the “root of my classpath”. I need confirmation on just how to do this in the eclipse environment. From the Package Explorer I have a package, Hibernate.Tutorial and have this file directly in this root. I have also tried to go through the Computer Environment variables for Classpath and but it there, but to no avail. I am new to Java and eclipse so I know I need to come up to speed in this area but, if someone would be so kind as to explain how to resolve this and if I don’t have the hibernate.cfg.xml in the right place give me a detailed explanation on how to get it there.

Thanks in advance.

 Post subject:
PostPosted: Sat Jun 09, 2007 5:52 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I think you want the regular Hibernate forum or tools forum. This is the forum for questions about two specific Hibernate books.

Get the book, training, and consulting for your Hibernate team.

 Post subject: Check the class path of the hibernate.cfg.xml
PostPosted: Tue Jul 31, 2007 11:28 am 

Joined: Tue Jul 31, 2007 11:00 am
Posts: 2

Kindly ensure that hibernate.cfg.xml are set in the class path or

InitSessionFactory class are load the hibernate.cfg.xml file.

check the class path.

Balakrishnan S.

Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.