Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsf + hibernate without another framework?

 
Teena George
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
 
tabiul mahmood
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
 
Freddy Wong
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.
 
Teena Mariam
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic