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?
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
It is possible, but it may not worth the effort. My advice is to use Seam framework to achieve that.
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
posted 10 years ago
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.
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.
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad: