Spring aop transaction not committing the transaction
I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache Tomcat 6.0.29.
I have used declarative transactions of spring for transaction management. The issue is that the transactions are not working for me. The transaction only works once and thereafter nothing.
I have tried checking all my configs but no clue. Any pointers?
My configurations looks like this -
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="dtxops"
expression="execution(* com.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
</aop:config>
EDIT after comment -------------
I start the server and e开发者_如何学Pythonxecute some transactional functionality and some times it works and some times it does not. Sometimes it keeps on working for 5-6 times and then suddenly it stops.
TX Manager and DS config -
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="resourceRef" value="true" />
<property name="jndiName" value="java:comp/env/jdbc/MyDBInstance" />
</bean>
Have you configured you datasource in Spring or Tomcat? (Tomcat has some weird default setting that auto commits after every statement which I guess makes it hard to run a DataSourceTransactionManager on top)
精彩评论