-->
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.  [ 2 posts ] 
Author Message
 Post subject: /hibernate.cfg.xml not found
PostPosted: Wed Oct 15, 2008 7:17 pm 
Newbie

Joined: Wed Oct 15, 2008 6:35 pm
Posts: 1
Location: San Francisco
I am trying to run the EventManager the very first tutorial and I am getting the following error where in it says hibernate.cfg.xml not found.

The file hibernate.cfg.xml not found is in the src folder and has been successfully copied over to the bin folder, but I am wondering why I am getting the error and how to fix this. I am very new to hibernate.


BUILD SUCCESSFUL
Total time: 1 second
C:\HibernateProjects\FirstProject>ant run -Daction=store
Buildfile: build.xml

clean:
[delete] Deleting directory C:\HibernateProjects\FirstProject\bin
[mkdir] Created dir: C:\HibernateProjects\FirstProject\bin

copy-resources:
[copy] Copying 4 files to C:\HibernateProjects\FirstProject\bin
[copy] Copied 2 empty directories to 1 empty directory under C:\HibernatePr
ojects\FirstProject\bin

compile:
[javac] Compiling 3 source files to C:\HibernateProjects\FirstProject\bin

run:
[java] SLF4J: This version of SLF4J requires log4j version 1.2.12 or later.
See also http://www.slf4j.org/codes.html#log4j_version
[java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg
.Environment).
[java] log4j:WARN Please initialize the log4j system properly.
[java] Initial SessionFactory creation failed.org.hibernate.HibernateExcept
ion: /hibernate.cfg.xml not found
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at util.HibernateUtil.<clinit>(Unknown Source)
[java] at events.EventManager.createAndStoreEvent(Unknown Source)
[java] at events.EventManager.main(Unknown Source)
[java] Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not
found
[java] at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHel
per.java:170)
[java] at org.hibernate.cfg.Configuration.getConfigurationInputStream(C
onfiguration.java:1439)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:
1461)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:
1448)
[java] ... 3 more
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 1 second

Thanks,

Manisha


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2008 4:32 am 
Beginner
Beginner

Joined: Tue Sep 09, 2008 5:42 am
Posts: 22
Location: Romania
Ciao,

When you configure the sessionFactory try to specify the path to your file in the Configure method. Something like this:

Code:
Configuration config = new Configuration().Configure("your path here");
ISessionFactory sessionFactory=config.AddAssembly(Assembly.GetExecutingAssembly()).BuildSessionFactory();


It should work also without specifying the path if the hibernate.cfg.xml is copied in the right place, but maybe doing like this you can figure out where you are doing wrong. Look also in the inner exception ...if you have that.

Good luck!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.