Issue Details (XML | Word | Printable)

Key: GRAILS-2764
Type: Improvement Improvement
Status: Closed Closed
Resolution: Duplicate
Priority: Minor Minor
Assignee: Graeme Rocher
Reporter: Kevin Richards
Votes: 9
Watchers: 8
Operations

If you were logged in you would be able to see more operations.
Grails

OpenSessionInView does not work with SiteMesh

Created: 01/Apr/08 10:58 AM   Updated: 08/May/09 08:38 AM   Resolved: 08/May/09 08:38 AM
Return to search
Component/s: View technologies
Affects Version/s: 1.0-RC2
Fix Version/s: 1.1.1

Time Tracking:
Not Specified

Environment: linux/windows


 Description  « Hide

The OpenSessionInView interceptor is applied to the UrlMappings filter and not the SiteMesh filter.

If the SiteMesh layouts access the database via taglibs or directly through GORM they will not be able to take advantage of an open Hibernate Session.

It would be better if the OSIV interceptor was applied to the SiteMesh filter rather than the UrlMappingFilter.



Graeme Rocher made changes - 01/Apr/08 11:46 AM
Field Original Value New Value
Fix Version/s 1.0.4 [ 14156 ]
Jean-Noël Rivasseau added a comment - 27/Jul/08 04:54 PM

This bug is hitting me too. The priority of this bug should be boosted to major at least I guess.


Peter Ledbrook added a comment - 10/Nov/08 03:21 AM

It might make sense to install the OpenSessionInViewFilter ahead of the SiteMesh filter rather than using the interceptor. The downside is that I doubt the session can be set to read-only (or FlushMode.MANUAL I believe) before the views are rendered.


Graeme Rocher added a comment - 10/Nov/08 08:06 AM

No the Filter approach is not an option, it is critical to set FlushMode to manual before view rendering to avoid changes being flushed from the view and potentially corrupting the markup if this happens after the view buffer has been flushed.


Graeme Rocher made changes - 14/Nov/08 07:34 AM
Fix Version/s 1.0.4 [ 14156 ]
Fix Version/s 1.0.5 [ 14721 ]
Jean-Noël Rivasseau added a comment - 27/Nov/08 07:29 AM

Is this bug hard to fix? It's becoming more and more problematic for me. I think its severity should be at least bumped to Major or more... if G2One does not have the resources to fix it soon I could try to have a look at it


Graeme Rocher added a comment - 27/Nov/08 09:53 AM

I wouldn't say its major, the solution is to eagerly initialize your association when querying or declaratively. It is currently something that is hard to fix and will need some careful thought on how we manage the session in the sitemesh layer


Jean-Noël Rivasseau added a comment - 27/Nov/08 10:27 AM

Yes, there is a workaround, but there are two problems:

  • the issue can be a turn-off for newcomers to Grails;
  • everytime i run into this issue, it's hard to find the actual cause and I lose a lot of time before realizing I've been hit by this bug -> quite bad for a high productivity framework such as Grails.

If it's hard to fix I will leave this to G2One then and hope you guys fix it soon enough


Peter Delahunty added a comment - 24/Feb/09 04:47 AM

I would also vote that this is a BIG issue.

I have a scenario where i have a template that is only referenced from a sitemesh layout. This template calls a tag lib. This means this template is outsite the open session in view interceptor so the session is already closed.

My template:

<g:form controller="account" action="choose">
<input type="hidden" name="currentController" value="${params.controller}">
<input type="hidden" name="currentAction" value="${params.action}">
<label for="accountSelectId">Change account: </label><g:accountListSelect id="accountSelectId" name="id" onchange="this.form.submit();"/>
</g:form>

So i have this tag lib:

def accountListSelect = {attrs,body ->
User user = User.get(session.userId)
def accountList = user.accountAccesses.collect {it.account};
attrs.from = accountList
attrs.optionKey = 'id'
attrs.optionValue = 'name'
attrs.value = session.accountId
out << g.select(attrs)
}

Here my call is:

User user = User.get(session.userId)
def accountList = user.accountAccesses.collect {it.account};

This will now throw a lazy load exception because the session is not closed.


Jean-Noël Rivasseau added a comment - 24/Feb/09 06:37 AM

Yes, I would hope it would be fixed for 1.1... does not look it actually will though


Kyle Pinette added a comment - 13/Mar/09 01:19 PM

Has anything been done about this??

This a major issue...I need to pull content from the database in a layout...

Right now, I'm making a call to open a session manually FROM THE LAYOUT. That seems like a really dirty work around.


Mos added a comment - 16/Mar/09 08:16 AM

It would be nice if this could be fixed soon. Somebody put this to 1.1.1?
The workaround with "solution is to eagerly initialize" doesn't work very well, if second-level cache is used (which should be standard )


Peter Delahunty added a comment - 16/Mar/09 08:36 AM

Gonna try some experiments to see what we can do for this.


Graeme Rocher made changes - 18/Mar/09 08:19 AM
Fix Version/s 1.0.5 [ 14721 ]
Fix Version/s 1.1.1 [ 15088 ]
Peter Delahunty added a comment - 18/Mar/09 09:17 AM

Hi Graeme

Out of interest what did you do to fix this ?


Graeme Rocher added a comment - 18/Mar/09 09:45 AM

It hasn't been fixed, the issue is stilll open


Graeme Rocher made changes - 08/May/09 08:38 AM
Resolution Duplicate [ 3 ]
Status Open [ 1 ] Closed [ 6 ]