简体   繁体   中英

No Transaction Applied when using AspectJ with iBatis, Spring

I am using iBatis 2.3.4 being called by an Axis 2 web service. I am using AspectJ weaving during the build.

I have the following Spring application context:

<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
    <property name="targetDataSource">
        <ref bean="dataSourceImpl" />
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
 </bean> 

<tx:annotation-driven transaction-manager="transactionManager" mode="aspectj" proxy-target-class="true"/>

I have a web service operation which has a @Transactional annotation, thus:

@Override
@Transactional(propagation=Propagation.REQUIRED)
public void  doStuff() {
    System.out.println("--> isActualTransactionActive: " + TransactionSynchronizationManager.isActualTransactionActive());        
  .
  .
  .

}

When I call the web service I see

--> isActualTransactionActive: false

as the transaction is never actually applied. Has anyone used AspectJ in combination with iBatis?

Have you enabled load-time weaving?

<context:load-time-weaver aspectj-weaving="on"/>

EDIT:

You'll probably also need:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" />
</Context>

in your META-INF/context.xml (to avoid having to use the -javaagent command line parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM