No Hibernate Session bound to thread

View: New views
9 Messages — Rating Filter:   Alert me  

No Hibernate Session bound to thread

by ray211 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Getting the following error:
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

My Grails service listens for JMS message.  Once received it writes that data to the database.  On the it.save() this exception is thrown.

Any suggestions?

Thanks!

Re: No Hibernate Session bound to thread

by Brad Booth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The hibernate session is bound to the request, try the background-
thread plugin it solves this.


Sent from my iPhone

On Jun 23, 2009, at 11:07 AM, ray211 <raystiegler@...> wrote:

>
> Getting the following error:
> org.hibernate.HibernateException: No Hibernate Session bound to  
> thread, and
> configuration does not allow creation of non-transactional one here
>
> My Grails service listens for JMS message.  Once received it writes  
> that
> data to the database.  On the it.save() this exception is thrown.
>
> Any suggestions?
>
> Thaks!
> --
> View this message in context: http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24169249.html
> Sent from the grails - dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: No Hibernate Session bound to thread

by ray211 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stupid question please!

Is the background-thread for the onMessage() of the DB write?


Brad Booth wrote:
The hibernate session is bound to the request, try the background-
thread plugin it solves this.


Sent from my iPhone

On Jun 23, 2009, at 11:07 AM, ray211 <raystiegler@gmail.com> wrote:

>
> Getting the following error:
> org.hibernate.HibernateException: No Hibernate Session bound to  
> thread, and
> configuration does not allow creation of non-transactional one here
>
> My Grails service listens for JMS message.  Once received it writes  
> that
> data to the database.  On the it.save() this exception is thrown.
>
> Any suggestions?
>
> Thaks!
> --
> View this message in context: http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24169249.html
> Sent from the grails - dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Re: No Hibernate Session bound to thread

by Brad Booth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The db operation, it basically provides a hibernate session outside a  
http request

Sent from my iPhone

On Jun 23, 2009, at 1:48 PM, ray211 <raystiegler@...> wrote:

>
> Stupid question please!
>
> Is the background-thread for the onMessage() of the DB write?
>
>
>
> Brad Booth wrote:
>>
>> The hibernate session is bound to the request, try the background-
>> thread plugin it solves this.
>>
>>
>> Sent from my iPhone
>>
>> On Jun 23, 2009, at 11:07 AM, ray211 <raystiegler@...> wrote:
>>
>>>
>>> Getting the following error:
>>> org.hibernate.HibernateException: No Hibernate Session bound to
>>> thread, and
>>> configuration does not allow creation of non-transactional one here
>>>
>>> My Grails service listens for JMS message.  Once received it writes
>>> that
>>> data to the database.  On the it.save() this exception is thrown.
>>>
>>> Any suggestions?
>>>
>>> Thaks!
>>> --
>>> View this message in context:
>>> http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24169249.html
>>> Sent from the grails - dev mailing list archive at Nabble.com.
>>>
>>>
>>> ---
>>> ------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>   http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24174186.html
> Sent from the grails - dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: No Hibernate Session bound to thread

by Brad Booth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://grails.org/plugin/background-thread has some info on how it is used.  This is one of the first plugins I always install.

On Tue, Jun 23, 2009 at 2:21 PM, Bradley Booth <bradley.booth@...> wrote:
The db operation, it basically provides a hibernate session outside a http request

Sent from my iPhone


On Jun 23, 2009, at 1:48 PM, ray211 <raystiegler@...> wrote:


Stupid question please!

Is the background-thread for the onMessage() of the DB write?



Brad Booth wrote:

The hibernate session is bound to the request, try the background-
thread plugin it solves this.


Sent from my iPhone

On Jun 23, 2009, at 11:07 AM, ray211 <raystiegler@...> wrote:


Getting the following error:
org.hibernate.HibernateException: No Hibernate Session bound to
thread, and
configuration does not allow creation of non-transactional one here

My Grails service listens for JMS message.  Once received it writes
that
data to the database.  On the it.save() this exception is thrown.

Any suggestions?

Thaks!
--
View this message in context:
http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24169249.html
Sent from the grails - dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

 http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email





--
View this message in context: http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24174186.html
Sent from the grails - dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email




Re: No Hibernate Session bound to thread

by ray211 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think I am real close.  However, I am still having a problem.  

When I try to do my DB write:
backgroundService.execute("DB Write " + count.toString(), {it.save()} )

I get the following error:
Caused by: groovy.lang.MissingMethodException: No signature of method: static RcdFact.save() is applicable for argument types: () values: []

Re: No Hibernate Session bound to thread

by Brad Booth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The closure should contain the database work that needs to be done.  In the example you game "it" will not be your object.  What you need to do is something like this...

backgroundService.execute("Whatever comment you like", {
  def foo = Foo.get(someId)
  foo.bar = "some value"
  foo.save()
}


On Tue, Jun 23, 2009 at 4:47 PM, ray211 <raystiegler@...> wrote:

I think I am real close.  However, I am still having a problem.

When I try to do my DB write:
backgroundService.execute("DB Write " + count.toString(), {it.save()} )

I get the following error:
Caused by: groovy.lang.MissingMethodException: No signature of method:
static RcdFact.save() is applicable for argument types: () values: []
--
View this message in context: http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24176403.html
Sent from the grails - dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Re: No Hibernate Session bound to thread

by ray211 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This still isn't working.  Let me paste my code:

class RvdRecordService {
   static expose = ['jms']
   static destination = "dataQueue"

   boolean transactional = false
   def backgroundService

def onMessage = {

   // This method will take my JMS msg and build a list of records from it.
   def curRecords = parseJson(it).toList()  

   // Looping through a list of records that were parsed from a JSON string received by a JMS msg.
   curRecords.each { curRcd ->
      if (curRcd) {
 
         backgroundService.execute("Whatever comment you like", {
            // RcdFact is a domain class.
            def myRcd = new RcdFact()
            myRcd.name = curRcd.name
            // etc...
            // At this point in the debugger myRcd has the proper data.
         
            // This line fails to save the record to the database.
            myRcd.save()
           } )
      }
   }
}

BTW, I know my connection to the database is valid.

THANKS AGAIN!!!

Brad Booth wrote:
The closure should contain the database work that needs to be done.  In the
example you game "it" will not be your object.  What you need to do is
something like this...

backgroundService.execute("Whatever comment you like", {
  def foo = Foo.get(someId)
  foo.bar = "some value"
  foo.save()
}


On Tue, Jun 23, 2009 at 4:47 PM, ray211 <raystiegler@gmail.com> wrote:

>
> I think I am real close.  However, I am still having a problem.
>
> When I try to do my DB write:
> backgroundService.execute("DB Write " + count.toString(), {it.save()} )
>
> I get the following error:
> Caused by: groovy.lang.MissingMethodException: No signature of method:
> static RcdFact.save() is applicable for argument types: () values: []
> --
> View this message in context:
> http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24176403.html
> Sent from the grails - dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

Re: No Hibernate Session bound to thread

by Brad Booth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What error message are getting now?  What is in the errors collection  
on your domain class?

Sent from my iPhone

On Jun 24, 2009, at 5:18 AM, ray211 <raystiegler@...> wrote:

>
> This still isn't working.  Let me paste my code:
>
> class RvdRecordService {
>   static expose = ['jms']
>   static destination = "dataQueue"
>
>   boolean transactional = false
>   def backgroundService
>
> def onMessage = {
>
>   // This method will take my JMS msg and build a list of records  
> from it.
>   def curRecords = parseJson(it).toList()
>
>   // Looping through a list of records that were parsed from a JSON  
> string
> received by a JMS msg.
>   curRecords.each { curRcd ->
>      if (curRcd) {
>
>         backgroundService.execute("Whatever comment you like", {
>            // RcdFact is a domain class.
>            def myRcd = new RcdFact()
>            myRcd.name = curRcd.name
>            // etc...
>            // At this point in the debugger myRcd has the proper data.
>
>            // This line fails to save the record to the database.
>            myRcd.save()
>           } )
>      }
>   }
> }
>
> BTW, I know my connection to the database is valid.
>
> THANKS AGAIN!!!
>
>
> Brad Booth wrote:
>>
>> The closure should contain the database work that needs to be  
>> done.  In
>> the
>> example you game "it" will not be your object.  What you need to do  
>> is
>> something like this...
>>
>> backgroundService.execute("Whatever comment you like", {
>>  def foo = Foo.get(someId)
>>  foo.bar = "some value"
>>  foo.save()
>> }
>>
>>
>> On Tue, Jun 23, 2009 at 4:47 PM, ray211 <raystiegler@...>  
>> wrote:
>>
>>>
>>> I think I am real close.  However, I am still having a problem.
>>>
>>> When I try to do my DB write:
>>> backgroundService.execute("DB Write " + count.toString(), {it.save
>>> ()} )
>>>
>>> I get the following error:
>>> Caused by: groovy.lang.MissingMethodException: No signature of  
>>> method:
>>> static RcdFact.save() is applicable for argument types: () values:  
>>> []
>>> --
>>> View this message in context:
>>> http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24176403.html
>>> Sent from the grails - dev mailing list archive at Nabble.com.
>>>
>>>
>>> ---
>>> ------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>   http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/No-Hibernate-Session-bound-to-thread-tp24169249p24183693.html
> Sent from the grails - dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email