org.hibernate.HibernateException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Setting the exposeTransactionAwareSessionFactory property on a Hibernate 3 LocationSessionFactoryBean to false will break transactional tests. Is this expected? It made me scratch my head for a while so I thought I'd report it. For instance, the following config: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="..." /> <property name="exposeTransactionAwareSessionFactory" value="false"/> <property name="hibernateProperties"> <props>...</props> </property> <property name="mappingDirectoryLocations" ref="..." /> <property name="mappingLocations" ref="..."/> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> Will cause this test to fail: @ContextConfiguration(locations = { "classpath:beans.xml" }) public class TestNGTest extends AbstractTransactionalTestNGSpringContextTests { @Autowired private SessionFactory sessionFactory; @Test public void testStuff() { sessionFactory.getCurrentSession().flush(); } } The same is true if you rewrite the test using classing JUnit: public class JUnitTest extends AbstractTransactionalSpringContextTests { private SessionFactory sessionFactory; protected String[] getConfigLocations() { return new String[] { "classpath:beans.xml" }; } public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } @Test public void testStuff() { sessionFactory.getCurrentSession().flush(); } } The error you get is: org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:542) at foo.bar.TestNGTest.testStuff(TestNGTest.java:19) at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:146)
    via by Erwin Vervaet,
  • Setting the exposeTransactionAwareSessionFactory property on a Hibernate 3 LocationSessionFactoryBean to false will break transactional tests. Is this expected? It made me scratch my head for a while so I thought I'd report it. For instance, the following config: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="..." /> <property name="exposeTransactionAwareSessionFactory" value="false"/> <property name="hibernateProperties"> <props>...</props> </property> <property name="mappingDirectoryLocations" ref="..." /> <property name="mappingLocations" ref="..."/> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> Will cause this test to fail: @ContextConfiguration(locations = { "classpath:beans.xml" }) public class TestNGTest extends AbstractTransactionalTestNGSpringContextTests { @Autowired private SessionFactory sessionFactory; @Test public void testStuff() { sessionFactory.getCurrentSession().flush(); } } The same is true if you rewrite the test using classing JUnit: public class JUnitTest extends AbstractTransactionalSpringContextTests { private SessionFactory sessionFactory; protected String[] getConfigLocations() { return new String[] { "classpath:beans.xml" }; } public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } @Test public void testStuff() { sessionFactory.getCurrentSession().flush(); } } The error you get is: org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:542) at foo.bar.TestNGTest.testStuff(TestNGTest.java:19) at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:146)
    via by Erwin Vervaet,
  • hibernate JNDI error
    via Stack Overflow by zeusakm
    ,
  • Hibernate "No CurrenetSessionContext "Error
    via Stack Overflow by EdgeCase
    ,
    • org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:542) at foo.bar.TestNGTest.testStuff(TestNGTest.java:19) at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:146)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,