RSSAll Entries Tagged With: "log4j.properties"

Hibernate Project Errors – Java – MYSQL 5.0

In this article I am sharing my experience on running my first Hibernate Project.

java-hibernate

I started with my first Hibernate project and followed the steps as instructed within the Tutorial. But on running it I was getting the below error.

[html]

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
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:170)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1453)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1475)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1011)
at com.hibernate.chapter.HelloEmployee.main(HelloEmployee.java:18)

[/html]

Resolution:

I had to spent some time to figure out what I missed and finally the issue was resolved.

The mistake I did was I pasted hibernate.cfg.xml and log4j.properties files thru Eclipse IDE and file got placed within the project root path as you see below.

img

The classpath would be SET to src and the project will search for these files within the scr folder on compile time; so you would need to move the two files manually into the src folder which will resolve the issue.

Hope this helped !