Announcement Announcement Module
Collapse
No announcement yet.
OpenSessionInViewInterceptor problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenSessionInViewInterceptor problem

    Hi,

    we use the OpenSessionInViewInterceptor in our application and did not experience any problems with it until today.

    We have the following scenario:

    We show a list of Objects to the user. Every object might have a collection of addresses which get fetched lazily while view rendering. This works perfectly when we show the list not using an iframe.

    If we show the list within an iframe we get the following exception:

    Code:
    10:34:07,468 DEBUG [OpenSessionInViewInterceptor] Opening single Hibernatesession in OpenSessionInViewInterceptor
    10:34:07,468 DEBUG [OpenSessionInViewInterceptor] Flushing single Hibernatesession in OpenSessionInViewInterceptor
    10:34:07,468 DEBUG [OpenSessionInViewInterceptor] Eagerly flushing Hibernatesession
    10:34:07,468 INFO  [OpenshopViewResolver] Cached view '/currency_list.html'
    10:34:07,468 ERROR [LazyInitializationException] Failed to lazily initialize a collection - no Session
    net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no Session
            at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:213)
            at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:69)
            at net.sf.hibernate.collection.Set.iterator(Set.java:131)
            at wilken.openshop.core.config.unit.Currency.getCurrencyDescr(Currency.java:224)
            at wilken.openshop.core.config.unit.Currency.getCurrencyDescr(Currency.java:215)
            at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:491)
            at ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:904)
            at ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:54)
            at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:122)
            at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1616)
            at ognl.ASTProperty.getValueBody(ASTProperty.java:96)
            at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
            at ognl.SimpleNode.getValue(SimpleNode.java:213)
            at ognl.ASTChain.getValueBody(ASTChain.java:109)
            at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
            at ognl.SimpleNode.getValue(SimpleNode.java:213)
            at ognl.Ognl.getValue(Ognl.java:333)
            at ognl.Ognl.getValue(Ognl.java:378)
            at ognl.Ognl.getValue(Ognl.java:357)
            at wilken.openshop.business.context.Ctx.getValue(Ctx.java:311)
            at wilken.openshop.business.parser.node.ReferenceNode.resolve(ReferenceNode.java:154)
            at wilken.openshop.business.parser.node.ReferenceNode.doResolve(ReferenceNode.java:122)
            at wilken.openshop.business.parser.node.ReferenceNode.execute(ReferenceNode.java:111)
            at wilken.openshop.business.parser.node.ReferenceNode.value(ReferenceNode.java:166)
            at wilken.openshop.business.parser.node.ReferenceNode.render(ReferenceNode.java:172)
            at wilken.openshop.business.runtime.tag.OSRepeated.render(OSRepeated.java:116)
            at wilken.openshop.business.parser.node.TagNode.render(TagNode.java:233)
            at wilken.openshop.business.runtime.tag.OSForeach.render(OSForeach.java:83)
            at wilken.openshop.business.parser.node.TagNode.render(TagNode.java:233)
            at wilken.openshop.business.parser.node.NodeSupport.render(NodeSupport.java:196)
            at wilken.openshop.business.parser.node.RootNode.render(RootNode.java:47)
            at wilken.openshop.business.resource.TemplateResource.merge(TemplateResource.java:222)
            at wilken.openshop.business.web.OpenshopView.mergeTemplate(OpenshopView.java:385)
            at wilken.openshop.business.web.OpenshopView.renderMergedOutputModel(OpenshopView.java:209)
            at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:238)
            at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:644)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:535)
            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    As everybody can see the Interceptor is called and the Hibernate Session should be there. But Hibernate complains about a missing Session.

    If I remove the iframe from the page and show the list there everything works great.

    Does anybody have a clue why this happens?

    Any help is greatly appreciated. Thanks.

    jd

  • #2
    The iframe issues a separate request, doesn't it? Are you sure you've configures you interceptor/filter in such a way that the iframe request also has the open session available?

    It just seems that in the parent document (containing the iframe), the interceptor/filter is there and in the iframe request, it isn't.

    Alef

    Comment


    • #3
      Weird, I answered this a couple of weeks ago, but can't find my post. Must have not hit save.

      Frames are indeed a separate request. In this case, I assume the data with the lazy relationship is saved in the HTTP session, and then attempted to be used when the separate request comes in for the frame? There's no way to use the OpenSessionInViewFilter to resolve this, since there are actually two requests here. You have to just ensure that the data is complete, or alternately, when servicing the request for the frame data, do a complete read again...

      Comment

      Working...
      X