Im running Struts, Tiles, Hibernate 2 and Spring in my project and have been attempting for some time to get the OpenSessionInView pattern to work without much luck.
I have the filter setup in my web.xml like so : <filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework.orm.hibernate.support.OpenSessionInViewFilter </filter-class> </filter> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> applicationContext.xml for various things is as follows: <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:/JournalDS</value> </property> </bean> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource"/> </property> <property name="mappingResources"> <list> <value>com/rave/journal/model/Activity.hbm.xml</value> . . . . . </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> net.sf.hibernate.dialect.Oracle9Dialect </prop> <prop key="hibernate.show_sql"> false </prop> </props> </property> </bean> <!-- Transaction manager for a single Hibernate SessionFactory --> <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> Looking at the log output it seems to be closing the Hibernate session after the first POJO is populated in my Action. The next piece of code tries to access a collection and bam, down it goes : . . . [net.sf.hibernate.impl.SessionImpl] executing flush [net.sf.hibernate.impl.SessionImpl] post flush [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [EMAIL PROTECTED] for key [EMAIL PROTECTED] from thread [Ajp13Processor[8009][4]] [org.springframework.orm.hibernate.SessionFactoryUtils] Closing Hibernate session [net.sf.hibernate.impl.SessionImpl] closing session [net.sf.hibernate.impl.SessionImpl] disconnecting session [net.sf.hibernate.impl.SessionImpl] transaction completion [net.sf.hibernate.LazyInitializationException] Failed to lazily initialize a collection - no session or session was closed All my mappings have lazy set to true. If I switch them all over to false the application does run. If I look at all the SQL generated with lazy set false though it is quite scary how much access is done. I've attached a bigger excerpt from the log if that will help track down the issue. Any ideas what would be causing the Hibernate session to be closed? If I understand things correctly the OpenSessionInViewFilter should be the thing closing the session (after everything has run in the Request. From the log it looks as if org.springframework.orm.hibernate.SessionFactoryUtils is doing it. I'd really appreciate some help here. This has been driving me nuts for days. Regards Marty Martin Ravell FMS Global --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]