"No session currently bound to execution context" using the legacy Hibernate interface in JBoss EAP

Solution Verified - Updated -

Issue

  • Using the legacy/native Hibernate interface (SessionFactory/Session) instead of the JPA interface (EntityManagerFactory/EntityManager)
  • hibernate.current_session_context_class is set to org.hibernate.context.internal.ManagedSessionContext
  • Encountering an exception while obtaining a Session reference

    ... org.hibernate.HibernateException: No session currently bound to execution context
        at org.hibernate.context.internal.ManagedSessionContext.currentSession(ManagedSessionContext.java:58)
        at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:497)
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7
  • Hibernate 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content