An exception occurs because you are trying to access the lazy loaded property of a domain object after the hibernate session into which it was loaded has been closed.
A common way to fix this is to use Spring OpenSessonInViewFilter. This greatly facilitates the hibernate session for your HTTP request. Then any access to the properties that occurs in this HTTP request / response cycle will be within the scope of this session.
You configure it in your web.xml as follows:
<filter> <filter-name>Spring OpenSessionInViewFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter>
Hope this helps.
source share