Announcement Announcement Module
No announcement yet.
JstlView+OpenSessionInViewFilter=LazyInitializationException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JstlView+OpenSessionInViewFilter=LazyInitializationException

    OK so I'm trying to use the JstlView resolver from SpringMVC with a bunch of hibernate DAOs. Thinking that the OpenSessionInViewFilter will save me from the horror of LazyInitializationExceptions, I create these DAOs with lazy collections in them.

    I pass the jsp page, the personService from which I get a personList. (This involves doing a session.find with the session being got from SessionFactoryUtils.getSession(sessionFactory,fals e).)

    I then iterate across the list and the children. However, as soon as I try to use iterate across a collection which is lazyinitialized I get a LazyInitializationException - no session or session closed.

    Unh? How do I fix this?


  • #2
    OK it turns out that the SessionFactory the OpenSessionInViewFilter is getting is different to the one that my DAOService is getting. How I don't know, since there is only one defintion of mySessionFactory and it is used by both.

    Any ideas why this is happening?


    • #3
      Right having read the similar Struts problem I decided to take a look at my servlet loading order. Changing these so that the ContextLoaderServlet loads first, and ensuring that the DispatcherServlet loads after that removes this problem. Could the reference doc be changed to take account of this problem please as this has just wasted an entire day. Thanks.