I just ran into a problem I don't understand. Our grails (2.2.2) app is throwing the following exception just after the first user logged in. Once that one's done, no one has ever seen it again. Currently we're reproducing it with a Geb test.
Caused by HibernateSystemException: connnection proxy not usable after transaction completion; nested exception is org.hibernate.HibernateException: connnection proxy not usable after transaction completion
->> 24 | doCall in gibbons5.recommender.ActivityRatingTagLib$_closure1
The line in the ActivityRatingTagLib (called by a gsp) is pretty simple:
if (!User.get(session.user.id).permissions.publishStream) {
If I remove the User.get()
here and access the session.user right away, everything works fine but then it crashes in the next TagLib call in which the User is accessed via User.get()
.
I was searching on the internet for solutions a lot now but nothing useful came up yet. As this exception seems to be rather uncommon, I guess we're doing something basically wrong, but what?
User.groovy:
class User implements HttpSessionBindingListener {
...
boolean isOnline = false
Permissions permissions = new Permissions()
static embedded = ['infoPopups', 'permissions', 'userSettings']
void valueBound(HttpSessionBindingEvent event) {
isOnline = true
}
void valueUnbound(HttpSessionBindingEvent event) {
// we do not have a session any more
withTransaction {
def user = get(this.id)
user.isOnline = false
user.save()
}
}
...
}
Permissions.groovy:
class Permissions {
boolean publishStream = false
}
Had the same exception thrown from a migration script, solved it in the following way (Grails 2.2.0):
User.withNewSession {
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With