Spring: 2.0.7
Hibernate Core: 3.2.5.ga
Hibernate Annotation: 3.3.0 GA
I am using Spring, Hibernate, C3P0 and MySQL in a stand-alone application. The app runs on its own and not in an application server or a container of any sort.
I keep getting the below error. I'd appreciate all pointers on what I may have done wrong. Thanks...
The log below is triggered by the following code:
sessionFactory.getCurrentSession();
20:41:50,953 DEBUG SessionFactoryUtils:315 - Opening Hibernate Session
20:41:51,015 DEBUG SessionImpl:220 - opened session at timestamp: 11929381109
20:41:51,015 DEBUG SessionFactoryUtils:771 - Closing Hibernate Session
20:41:51,015 ERROR GeoLocEditorService:51 - ***Exception***
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.AbstractSession FactoryBean$TransactionAwareInvocationHandler.invo ke(AbstractSessionFactoryBean.java:300)
at $Proxy17.getCurrentSession(Unknown Source)
===
My service method is annoated with @Transactional.
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="configLocation" value="/hibernate.cfg.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- Hibernate Transaction Manager -->
<bean id="txManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>


Reply With Quote

