• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use hibernate with servlet

 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I am new to Hibernate. I just want to run sample application using Hibernate using Tomcat. I read some articles on internet but i am unable to find directory structure. Can anyone provide some link which explains from starting to deployment.

Thanks in advance
 
shiva valanukonda
Greenhorn
Posts: 26
Hibernate jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
this is quite easy to integrate Hibernate with Servlet with the following steps.
Step 1: Create a servlet with init() , service() and destroy().
Step 2: Create a SessionFactory Object inside the init() of servlet and store it into serlvetContext inteface .
Step 3: Call the SFactory object fron SContext using getServletcontext(Obje) inside the service() and remaining thing (creating session obj) is same.
Step 4: Directory Structure is
War
jsps,html
WEB-INF
web.xml
Classes
POJOs,.classes and *.cfg.xml, *.hbm.xml

But, If you really required any link on this topic please seach it in Google.
thanks
Shiva
 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shiva valanukonda wrote:Hi,
this is quite easy to integrate Hibernate with Servlet with the following steps.
Step 1: Create a servlet with init() , service() and destroy().
Step 2: Create a SessionFactory Object inside the init() of servlet and store it into serlvetContext inteface .
Step 3: Call the SFactory object fron SContext using getServletcontext(Obje) inside the service() and remaining thing (creating session obj) is same.
Step 4: Directory Structure is
War
jsps,html
WEB-INF
web.xml
Classes
POJOs,.classes and *.cfg.xml, *.hbm.xml

But, If you really required any link on this topic please seach it in Google.
thanks
Shiva



Hey Shiva i did what you asked but tomcat gives error
"java.lang.NoClassDefFoundError: org/dom4j/DocumentException".....
What to do now!
 
shiva valanukonda
Greenhorn
Posts: 26
Hibernate jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Jagdeep,
make sure that , you have mentioned the exact path loaction of the mapping file and class file in configuration file. Otherwise you will get this type of problems only.

and make sure that the dom4j.jar file is place in WEB-INF/lib folder ok.

Thanks
Shiva
 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shiva valanukonda wrote:Hey Jagdeep,
make sure that , you have mentioned the exact path loaction of the mapping file and class file in configuration file. Otherwise you will get this type of problems only.

and make sure that the dom4j.jar file is place in WEB-INF/lib folder ok.

Thanks
Shiva



Shiva,

I placed mapping files(xml files) in classes folder (I am using default java package). dom4j.jar is there in lib folder.
Can you provide me some good link for my purpose.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic