mph
mph

Reputation: 868

HibernateException: No session currently bound to execution context

I'm trying to create a very basic REST-ish web service with Grails and Postgres. I have the read() & delete() methods working, but I can't get create() to work. Hibernate just gripes, "HibernateException: No session currently bound to execution context." Here's my create method:

def create = {
  def member = new Member(params)
  member.save()
  render(status: 201)
}

Any advice would be great. Thanks.

Upvotes: 1

Views: 2848

Answers (1)

mph
mph

Reputation: 868

Problem solved!

Since I have EJB3 annotation files as my Grails domain classes, I had to create my own hibernate.cfg.xml for the mappings. I tried changing from

<property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property>

to

<property name="current_session_context_class">thread</property>

They both produced Hibernate session errors. Then I finally found this discussion which suggests you shouldn't have this property in your Hibernate config file at all.

Upvotes: 1

Related Questions