Announcement Announcement Module
No announcement yet.
OpenSessionInViewFilter does not work first time in web app Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenSessionInViewFilter does not work first time in web app


    I have the following scenario

    Hibernate DAO's using Spring's HibernateTemplate.

    These DAOs are referenced by a service layer that wraps the calls in transactions (no EJBs - Interface21, you have no idea how grateful I am for that).

    All the Hibernate associations are lazy.

    I use the OpenSessionInViewFilter to cope with lazy initialisation in the web layer (Struts).

    What is happening is that I click on a button on a web page, and it calls a "customer search" method on the service object from a Struts action. This works fine. The struts action then tries to map the data from the search back to form fields (i.e. tries to access lazy assocations). I get a

    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed

    exception even though I am using the OpenSessionInViewFilter.

    I hit back on the browser to get away from the error page, click on the search again, and it all works fine, and does so for any subsequent search.

    I'm at a bit of a loss to know what is going on here, has anyone seen anything similar ?