• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem in building hibernate SessionFactory

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 (TestHibernateServlet.java:35)

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

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yes,I see. I added some libs and solved above problem. Now I have following libraries in my lib for hibernate

hibernate3.jar
antlr-2.7.6.jar
commons-collations-3.1.jar
dom4j-1.6.1.jar
javassist-3.9.0.GA.jar
jta-1.1.jar
slf4j-api1.5.8.jar

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?


 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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



 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its very simple.. you need to add a library... This website http://www.compiletimeerror.com/2013/06/javalangnoclassdeffounderror_7.html explains about it.. Have a look..
 
CLUCK LIKE A CHICKEN! Now look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic