Announcement Announcement Module
No announcement yet.
Using @SessionAttributes(type = ) with OpenSessionInViewFilter Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using @SessionAttributes(type = ) with OpenSessionInViewFilter

    I have an app which has been using hibernate lazy-initialization and the OpenSessionInViewFilter. Using petclinic as an example, I have been trying to bind a form backing object using the @SessionAttributes annotation.

    When I use @SessionAttributes(type=GtdTask.class) I get the following error:

    WARNING: StandardWrapperValve[gtd]: PWC1406: Servlet.service() for servlet gtd threw exception
    org.springframework.web.HttpSessionRequiredExcepti on: Session attribute 'gtdTask' required - not found in session
    at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter$ServletHandlerMethodIn voker.raiseSessionRequiredException(AnnotationMeth
    at ndlerMethodInvoker.resolveModelAttribute(HandlerMe

    If I use @SessionAttributes("gtdTask"), everything works.
    If I turn off lazy-initialization in my hibernate xml config, everything works.

    Although I have two workarounds, why doesn't my original setup work?