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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Derek Alexander
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

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

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

Graeme Rocher-2
Please report an issue

On Fri, Jul 7, 2017 at 5:48 PM, Derek Alexander
<[hidden email]> wrote:

> 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
>
> --
> 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 [hidden email].
> To post to this group, send email to [hidden email].
> 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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAO_wNod0s%3DF2cFagKSxvgy065brkNe-xBAVBFaz8_aAqQkpGew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.