Announcement Announcement Module
Collapse
No announcement yet.
Using @SessionAttributes(type = ) with OpenSessionInViewFilter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 odHandlerAdapter.java:698)
    at org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.resolveModelAttribute(HandlerMe thodInvoker.java:757)
    [etc.]

    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?
Working...
X