grails/gradle shell in 3.2.9 - No Session found for current thread

312 views
Skip to first unread message

Derek Alexander

unread,
Jul 7, 2017, 11:48:37 AM7/7/17
to Grails Dev Discuss
Hi,

With grails 2.x the grails shell already seemed to have a hibernate session set up for the shell session:

One could do things like:

mdc MyDomainClass.get(1)
println mdc

straight away.

With grails 3.2.9 (running the shell using: gradle shell -q), doing the same gets me:

ERROR org.springframework.dao.DataAccessResourceFailureException:
Could not obtain current Hibernate Session; nested exception is org.hibernate.HibernateException: No Session found for current thread

Database access seems to be configured properly, as with hibernate trace logging on I can see it working during startup.

Also, this works:

MyDomainClass.withNewSession {
  mdc = MyDomainClass.get(1)
  println mdc
}

However, the session is closed when that block is exited.

Is there any way to get a hibernate session running that can be used for the whole shell session as it used to be in the past (2.x).

I used to find grails shell very useful in the past.

Cheers,
Derek

Graeme Rocher

unread,
Jul 11, 2017, 5:22:23 AM7/11/17
to grails-de...@googlegroups.com
Please report an issue
> --
> You received this message because you are subscribed to the Google Groups
> "Grails Dev Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to grails-dev-disc...@googlegroups.com.
> To post to this group, send email to grails-de...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grails-dev-discuss/6f06605b-5ed3-4bfd-a1df-dd6bf9adf656%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Graeme Rocher
Reply all
Reply to author
Forward
0 new messages