This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having problem in Spring3 using hibernate

Ishant Agarwal
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!! Guys

I am new in Spring and try to create an application using hibernate 3.2 but it gives me an exception like

org.apache.jasper.JasperException: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

My Dao bean are defined as:
<bean id="propertyConfigure"
p:location="/WEB-INF/" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}"></bean>

<bean id="sessionFactory"
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<property name="configurationClass">
<property name="hibernateProperties">
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>

<bean id="transactionManager"
<property name="sessionFactory" ref="sessionFactory" />

My DaoImplementation class

package com.customercare.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.customercare.model.User;

public class UserDaoImpl implements UserDao {
private SessionFactory sessionFactory ;

public void addUser(User user) {
sessionFactory.getCurrentSession().save(user) ;

public List<User> listUser() {
return sessionFactory.getCurrentSession().createQuery(" from user" ).list() ;


Pl help me out

Mark Spritzler
Posts: 17276
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you start up a Transaction before you called that code. So I assume you have Service classes and on those methods are you using @Transactional and have <tx:annotation-driven/> in your xml?

The error is saying that there isn't a Transaction running and Hibernate cannot run without a Transaction running.


ntumba lobo
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you set up the OpenSessionInViewFilter in your web.xml ?
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic