I am trying to use the OpenSessionInViewFilter in tandem with EJB CMT (can't use Spring tx management for political reasons). The filter is opening and closing a Hibernate Session at the beginning and end of a web request as expected. The problem is that the underlying Connection is being closed by the container (in my case, JBoss 3.2.2) upon completion of the (declaratively configured as "RequiresNew") transaction. Thus when a property is lazy-loaded later in the view, the result is the "net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection" message.
So - is there a way to obtain a Session using the filter and be assured that its connection will remain open for the duration of the request? Or, if not, is there a way to configure the Session through Spring to reconnect to obtain a new underlying Connection if it has been closed prior?


Reply With Quote
