History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-674
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Graeme Rocher
Reporter: Jason Rudolph
Votes: 0
Watchers: 0
Operations

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

Problem Redisplaying Record After Validation Occurs Error During Update

Created: 28/Jan/07 08:50 PM   Updated: 08/Mar/07 12:32 AM
Component/s: None
Affects Version/s: 0.4
Fix Version/s: 0.4

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive racetrack-bug-report-28012007.zip (15 kb)

Environment: Windows XP SP2, JDK 1.4.2_13


 Description  « Hide
Problem can be recreated using the attached bug report file.

1. Start app.
2. Navigate to http://localhost:8080/racetrack/race
3. Click "Create Race"
4. Enter valid data (shown below) and click "Create."

Name: Some Race
Date: Any future date
City: Some City
State: NC
Distance: 6.2
Cost: 20
Max Runners: 100000

5. Click "Edit" to edit the race.
6. Clear the text from the "Name" field.
7. Click "Update" to attempt to save a race with no name. (This will trigger a validation error.)
8. System redisplays partial page showing the validation error, but missing several fields and buttons.

Grails outputs following stack trace:

[copy] Copying 10 files to C:\dev\projects\racetrack\web-app\WEB-INF\grails-app\views
failed to lazily initialize a collection of role: Race.registrations, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: Race.registrations, no session or session was closed
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:681)
	at gjdk.org.hibernate.collection.PersistentSet_GroovyReflector.invoke(Unknown Source)
	at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
	at org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:109)
	at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:559)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:449)
	at org.codehaus.groovy.runtime.Invoker.invokePojoMethod(Invoker.java:129)
	at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:117)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodNSafe(ScriptBytecodeAdapter.java:195)
	at race_edit_gsp$_run_closure4.doCall(edit.gsp:102)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:69)
	at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:559)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
	at race_edit_gsp$_run_closure4.doCall(edit.gsp)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:69)
	at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:559)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:449)
	at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:140)
	at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:121)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeClosure(ScriptBytecodeAdapter.java:626)
	at FormTagLib$_closure6.doCall(FormTagLib:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:69)
	at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:559)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:449)
	at groovy.lang.Closure.call(Closure.java:188)
	at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:200)
	at gjdk.race_edit_gsp_GroovyReflector.invoke(Unknown Source)
	at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
	at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:559)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
	at race_edit_gsp.run(edit.gsp:131)
	at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine$GroovyPageTemplateWritable.writeTo(GroovyPagesTemplateEngine.java:418)
	at org.codehaus.groovy.grails.web.pages.GroovyPagesServlet.doPage(GroovyPagesServlet.java:154)
	at org.codehaus.groovy.grails.web.pages.GroovyPagesServlet.doPost(GroovyPagesServlet.java:116)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
	at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473)
	at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:280)
	at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:171)
	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:112)
	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:249)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:827)
	at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:84)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:736)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
	at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:830)
	at org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletFilter.java:170)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
	at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
	at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
	at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)
	at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
	at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
	at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:53)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
	at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
	at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1565)
	at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:635)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1517)
	at org.mortbay.http.HttpServer.service(HttpServer.java:954)
	at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
	at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983)
	at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
	at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
	at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
	at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Graeme Rocher - 29/Jan/07 10:30 AM
Although this is a problematic issues. I don't think we can have it block the release. At the moment it occurs when you have a collection that is lazy and you try to access that collection in the view

We'll fix this one promptly for 0.5, but we can't delay the release any longer as this fix for this one is complicated and requires a major re-think about the way we do validation


Barry Lagerweij - 08/Mar/07 12:32 AM
A temporary workaround may be the following: Add the following snippet to your web.template.xml file :

<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.codehaus.groovy.grails.orm.hibernate.support.GrailsOpenSessionInViewFilter
</filter-class>
</filter>

<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

I guess that eventually this should be moved to the HibernateGrailsPlugin.groovy, to 'doWithWebDescriptor'.