LazyInitializationException: could not initialize proxy – no Session

The error ”org.hibernate.LazyInitializationException: could not initialize proxy – no Session” has been giving me a headache for the last couple of days. So many people on the Internet have different answers and solutions to this error. The web-app that I am working on is made with Java + Resin + Spring + Hibernate + JSP + Stripes. This error occurs when the session is no longer active.

Add this to your web.xml file and sessions should be open during the entire request.


<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Works for me! Read more about OpenSessionInViewFilter

Kommentera

E-postadressen publiceras inte. Obligatoriska fält är märkta *

Denna webbplats använder Akismet för att minska skräppost. Lär dig hur din kommentardata bearbetas.