I'm using Struts + Hibernate + Spring for my project development. And here is my Spring Context XML file. When I called "sessionFactory.getCurrentSession()" in the beginning of userDao.getXXXX method, the exception whose detail message is "No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here" was thrown.
<!-- Hibernate Configuration -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- Spring Transaction Manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- Spring Transaction Descriptions -->
<bean id="transactionAttributeSource"
class="org.springframework.transaction.interceptor.MethodMapTransactionAttributeSource">
<property name="methodMap">
<map>
<entry key="com.miaozhen.monitor.service.LoginServiceImpl.*">
<value>PROPAGATION_REQUIRED</value>
</entry>
</map>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributeSource">
<ref bean="transactionAttributeSource"/>
</property>
</bean>
<bean id="transactionAdvisor"
class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
<constructor-arg>
<ref bean="transactionInterceptor"/>
</constructor-arg>
</bean>
<bean id="autoproxy"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
</bean>
<!-- DAO -->
<bean id="userDao"
class="com.miaozhen.dbservice.hibernate.dao.AUserDAO">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- Service Layer -->
<bean id="loginService"
class="com.miaozhen.monitor.service.LoginServiceImpl">
<property name="userDao">
<ref bean="userDao"/>
</property>
</bean>
<!-- Struts Actions for DelegatingActionProxy -->
<bean name="/login"
class="com.miaozhen.monitor.struts.action.LoginAction">
<property name="loginService">
<ref bean="loginService"/>
</property>
</bean>