Grails Webflow: error cannot initialize proxy - no session when trying to access the domain set in PageScope

We have our own tag, similar to g: set, which sets the current user to PageScope <n:currentUser var="foobar"> . It works fine until we have a stream.

For a stream view state that uses the tag above, it will throw Lazy an initialization exception of “cannot initialize proxies without a session”, even if the user is loaded into the same request and set to pagecope.

Does Webflow Affect OpenSessionInView! What is wrong here. What could be the solution, besides the one that wants to receive and convey the modal explicitly.

(The tag is actually in the layout, which is used to represent the state of the view)

UPDATE

I just noticed that even when accessing an object immediately after loading it, it still gives the same error. So these are not the PageScope objects causing the problem.

Inside tag

 User user = User.get(x) println user.foo.bar gives the same error 

It seems that for thread actions, the session does not remain open at all and appears to be closed immediately after the operation is completed.

thanks

+2
spring-webflow grails
source share
1 answer

I saw this error before and is not related to the web stream, but using the tag inside the layout. In this case, the layout is processed after the session is closed, and you need to create a new session manually.

 def currentUser = { attrs -> User.withTransaction { User user = User.get(x) } } 

JIRA's status will not be fixed because it is not good practice to make GORM requests inside TagLib.

+1
source share

All Articles