This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes org.hibernate.LazyInitializationException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org.hibernate.LazyInitializationException" Watch "org.hibernate.LazyInitializationException" New topic


Todd Smith

Joined: Dec 16, 2010
Posts: 25
I am getting a Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: gov.michigan.mdch.ibs.domain.Users.userRoleses, no session or session was closed.

I am using JQUERY for my Ajax to call the controller. The Controler will pass back a JSON object to be render in a div tag on the JSP
I know the user bean I am trying to return has 2 children tables. I have included the user bean and the DAO. I have tried the OpenSessionInViewFilter in the web.xml and that is not working. I just wanted to know if you had any ideas.

Gerardo Morales

Joined: Jan 10, 2012
Posts: 3
You could try to use interceptors instead of filters. Anyway, the OpenSessionInViewFilter should work fine.

Did you do a filter mapping after defining the filter on the web.xml?

You can find an example of a web.xml file and you can also download a little sample project that uses OpenSessionInViewFilter here:

Good luck!
Have you checked out Aspose?
subject: org.hibernate.LazyInitializationException
It's not a secret anymore!