This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!