File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

failed to lazily initialize a collection of role

 
Jack Rackham
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I execute a query in my controller, then I pass the results (I checked, they're correct) by chaining it to another page. Anyway I've the following message :
Error 500:
Servlet: default
URI: /package/recherche/list
Exception Message: failed to lazily initialize a collection of role: package.Profil.competences, no session or session was closed
Caused by: Error processing GroovyPageView: failed to lazily initialize a collection of role: package.Profil.competences, no session or session was closed
Class: /WEB-INF/grails-app/views/recherche/list.gsp
At Line: [-1]


With the stack :
2011-09-23 11:37:17,977 [http-9090-2] ERROR view.GroovyPageView - Error processing GroovyPageView: failed to lazily initialize a collection of role: package.Profil.competences, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: package.Profil.competences, no session or session was closed
at home_user_Projets_package_grails_app_views_recherche_list_gsp$_run_closure2_closure35.doCall(home_user_Projets_package_grails_app_views_recherche_list_gsp:89)
at home_user_Projets_package_grails_app_views_recherche_list_gsp$_run_closure2.doCall(home_user_Projets_package_grails_app_views_recherche_list_gsp:76)
at home_user_Projets_package_grails_app_views_recherche_list_gsp$_run_closure2.doCall(home_user_Projets_package_grails_app_views_recherche_list_gsp)
at home_user_Projets_package_grails_app_views_recherche_list_gsp.run(home_user_Projets_package_grails_app_views_recherche_list_gsp:104)
at java.lang.Thread.run(Thread.java:679)
2011-09-23 11:37:18,051 [http-9090-2] ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [GET] /package/recherche/list
Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: failed to lazily initialize a collection of role: package.Profil.competences, no session or session was closed
at java.lang.Thread.run(Thread.java:679)
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: package.Profil.competences, no session or session was closed
at home_user_Projets_package_grails_app_views_recherche_list_gsp$_run_closure2_closure35.doCall(home_user_Projets_package_grails_app_views_recherche_list_gsp:89)
at home_user_Projets_package_grails_app_views_recherche_list_gsp$_run_closure2.doCall(home_user_Projets_package_grails_app_views_recherche_list_gsp:76)
at home_user_Projets_package_grails_app_views_recherche_list_gsp$_run_closure2.doCall(home_user_Projets_package_grails_app_views_recherche_list_gsp)
at home_user_Projets_package_grails_app_views_recherche_list_gsp.run(home_user_Projets_package_grails_app_views_recherche_list_gsp:104)


I thought it was because of a lazy loading, Grails doco says that "In GORM, one-to-one and many-to-one associations are by default non-lazy". I've looked at the side of scopes, but I found nothing. Anyway, I've tried to code explicit eager behavior, still no success.

One word about my query : I recover datas from a many to many relationship, but I created the intermediate table (Competence) because I wanted to add informations.

Here is the code :







And ProfilController, which receives the parameters (only the usefull part)
 
Jack Rackham
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I pseudo-resolved this via a hack. Instead of sending the results to the closure of the controller corresponding to the page, I've modified the receiver controller to do the treatment then passing the results to the page.

But I still don't know why the results disappear when I pass the list to another url. I'm really interested in this. If someone has the answer...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic