Meaningless Drivel is fun!
The moose likes Object Relational Mapping and the fly likes Problem in building hibernate SessionFactory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem in building hibernate SessionFactory" Watch "Problem in building hibernate SessionFactory" New topic

Problem in building hibernate SessionFactory

Yewint Ko
Ranch Hand

Joined: Aug 02, 2009
Posts: 90
Hi all , I have some problems with hibernate configuration..... somebody help me please...
this is my dir structure

I build the SessionFactory in the servlet (TestHibernateServlet.class) as follow

I put the Hibenate jar file in lib correctly but I got this exception

java.lang.NoClassDefFoundError: org/dom4j/DocumentException (

Please help me out .I am new to hibernate, I don't know what to do .

Vasily Kukhta

Joined: Jan 17, 2009
Posts: 23
Hello! Does your application contain dom4j jar file? If not, you should add it.
Usually, NoClassDefFoundError occures if some required jar is not present in the application.
Yewint Ko
Ranch Hand

Joined: Aug 02, 2009
Posts: 90
Oh yes,I see. I added some libs and solved above problem. Now I have following libraries in my lib for hibernate


But when I run the app ,I see another error

and then I run again I got another error

Every first times after starting the server is first error and every second times is the last error. Why are the two errors different?
What will I do now? Do I need more libraries?

xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 137
hibernate.cfg.xml and other hbm file you have kept in WEB-INF directory. You should need to place inside /WEB-INF/classes.

Try this one.
Yewint Ko
Ranch Hand

Joined: Aug 02, 2009
Posts: 90
Yes I did. But I can't solve.
Actually, I think the problem is not with hibernate.cfg.xml file and .hbm.xml files. It might be because of lib files.
As for the first error, it said " java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder ".
When I take a look inside slf4j.jar, I don't see any such package "org/slf4j/impl/....". Something wrong?
This is how I write in my servlet

Prabu Dhanapal

Joined: Aug 12, 2011
Posts: 21
Its very simple.. you need to add a library... This website explains about it.. Have a look..
I agree. Here's the link:
subject: Problem in building hibernate SessionFactory
It's not a secret anymore!