Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No session currently bound to execution context

Tags:

I got below exception when I used session.getCurrentSession().

I have mentioned

hibernate.current_session_context_class: managed  org.hibernate.HibernateException: No session currently bound to execution context     at org.hibernate.context.internal.ManagedSessionContext.currentSession(ManagedSessionContext.java:75)     at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)     at io.dropwizard.hibernate.AbstractDAO.currentSession(AbstractDAO.java:36)     at io.dropwizard.hibernate.AbstractDAO.persist(AbstractDAO.java:149) 

I use this with dropwizard. Can anyone help me to solve this?

like image 469
Srinivas Avatar asked May 13 '15 10:05

Srinivas


1 Answers

If you are using Dropwizard Hibernate. You need to add @UnitOfWork annotation to your Resource method. More info within dropwizard manual, hibernate chapter.

like image 178
yunspace Avatar answered Oct 01 '22 22:10

yunspace