• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

HibernateException:Could not obtain transaction-ynchronized Session for current thread

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are migrating from Spring 1.5 and Hibernate 3.X to Spring 4.X and Hibernate 4.x and we are getting the below exception,

[EXCEPTION CLASS: org.hibernate.HibernateException]
[EXCEPTION MESSAGE: Could not obtain transaction-synchronized Session for current thread]
[EXCEPTION STACK TRACE: org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134)
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:993)
at VDaoImpl.getDAO(VDaoImpl.java:11)

Source Code :

Context file :

<bean id="VDao" class="VDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>

<bean id="commandHandlerDefaultProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<property name="interceptorNames">

<bean id="transactionManager"
class="org.springframework.transaction.jta.WebLogicJtaTransactionManager" />

<bean id="requiredTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<prop key="*">PROPAGATION_REQUIRED</prop>

DAO Class:

Before Migration :
public class VDaoImpl extends HibernateDaoSupport

public VObj getVehicleByVIN(String name)
Criteria spCriteria = this.getSession().createCriteria(VDaoImpl.class);

return VObj;


After Migration :

public class VDaoImpl

private SessionFactory sessionFactoryNew;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactoryNew = sessionFactory;

public VObj getDAO(String name)
// Getting exception in the below line
Criteria spCriteria = his.sessionFactoryNew.getCurrentSession().createCriteria(VDaoImpl.class);

return VObj;


Any help appreciated.
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you use the code tags.
    Bookmark Topic Watch Topic
  • New Topic