Spring Annotation driver Transaction with AspectJ problem

若如初见. 提交于 2019-12-11 02:23:01

问题


i am using AspectJ compile time weaving and spring 3.O. and Hibernate 3.0...AspectJ weaving is working fine for simple things like logging but this is not working correctly for Transaction

<tx:annotation-driven transaction-manager="transactionManager"
    mode="aspectj" order="1" />
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

Sprong-aspects jar is also present in the lib forlder but still transactional support is not working..

i am using like this

@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void invokeService() throws Exception {
    insertUpdatePolicy();
}

logging doesn,t specify any transactions..transactions are working fine with spring aop but not with aspectj when the class is not defined in the spring container


回答1:


Please post the actual code that is failing.

Enable logging. Check the logs to see if transactions are even being managed at all. If they are, then there is probably an issue with how you configured the transactions.




回答2:


i have found answer to this problem,

One thing we need to keep in mind that we need to place spring-aspects.jar to my Aspect Path instead of java class path.otherwise weaving is not done and transaction is not working.

Second thing i was missing following configuration in spring=bean config.

<bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf">
<property name="transactionManager" ref="transactionManager"/>



来源:https://stackoverflow.com/questions/7253118/spring-annotation-driver-transaction-with-aspectj-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!