• 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

jsf + hibernate without another framework?

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello,

I have a web application for which the data access layer uses pure JDBC. Now I am trying to persist data using hibernate. I removed my jdbc code and replaced it with hibernate code. But i have a problem here with the persistence context.
My web app is developed in JSF. So I have a faces-config.xml file. And I am declaring all the managed beans in the faces-config. So all my beans are in the current session and in a persistence context. But when i added the .hbm.xml file for each bean i have, it threw an exception saying "webappclassloader previously initiated loading for a different type with name org/hibernate/configuration". So i think the beans are being created twice: once in when the app is deployed, and two when it reads my hibernate.cfg.xml file. it I was searching for the options to rectify this. then i came across Seam2 framework. It seems like i can use Seam framework to rectify these problems. But is there any way to rectify the error without using another framework?



Regards,
Teena
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope that you are not declaring your JSF Managed bean as a hbm.xml file. Faces-Config.xml is ony meant for JSF Managed Beans like Backing Bean etc. While your hbm.xml file is meant for your database tables and only those should be specified in your cfg.xml file
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible, but it may not worth the effort. My advice is to use Seam framework to achieve that.
 
tabiul mahmood
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My feeling is that there is some configuration mistake that Teena is making that is causing this problem. JSF and Hibernate is two different framework that serves different purpose and I personally used them together and there are no problems using them together.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for the response. Frankly, I am too confused to answer Taibul's guess. But, yes, you could be right. let me take one more detailed look at what i need to keep as managed beans and what i do not have to. (I don't have any ejb components. All i have is jsf backing beans.)

Sorry for the delayed reply.

Thanks,
Teena
 
I don't like that guy. The tiny ad agrees with me.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic