15
I am using Spring 3 with Hibernate 3. I am trying to configure Spring declarative transaction, but no matter what I try, Spring transaction is not getting started.
Here is my configuration
File: applicationContext-hibernate.xml
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="mdbDataSource" class="org.apache.commons.dbcp.BasicDataSource">
...
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="mdbDataSource" />
<property name="annotatedClasses">
.....
</bean>
I have a class ServiceLocatorImpl which implements ServiceLocator interface
@Service("serviceLocator")
@Transactional
public class ServiceLocatorImpl implements ApplicationContextAware, Serializable, ServletContextAware, ServiceLocator {
public ResultObject executeService( Map objArgs )
{
if(TransactionSynchronizationManager.isActualTransactionActive()) {
LOGGER.debug("ServiceLocator:executeService - Active transaction found");
} else {
LOGGER.error("No active transaction found");
}
......
}
....
}
It seems to me that all my configuration is correct. But when executeService method is called, TransactionSynchronizationManager.isActualTransactionActive() is always returning false.
Please help me solving this problem. Let me know if any more information required.
Update: I have wired the ServiceLocator into one of the other classes, as follows:
@Autowired
private ServiceLocator serviceLocator; // ServiceLocator is interface
I am using Spring 3.0.0 version.
executeServi