PDA

View Full Version : No TransactionInterceptor-managed TransactionStatus in scope



cig
Sep 20th, 2004, 05:20 AM
Hi

I have used declarative transaction management to specify that a method called, add(Deal) on a class called DealsHolder should be executed within a transaction. Below is the declaration from the applicationContext.xml :



<bean id="ptm" class="org.springframework.orm.jdo.JdoTransactionManager">
<property name="persistenceManagerFactory">
<ref bean="pmf"/>
</property>
</bean>

<bean id="dealsHolderTarget" class="za.co.rmb.spj.deals.domain.DealsHolder"/>

<bean id="dealsHolder" class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<property name="transactionManager">
<ref bean="ptm"/>
</property>
<property name="target">
<ref bean="dealsHolderTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

When I executed the code, I was getting an exception stating that there is no active transaction available. So I put a println into the add(Deal) method where I'm checking what the current TransactionStatus is, just prior to invoking the add method. This is what I got back:



Exception in thread "main" org.springframework.transaction.NoTransactionExcep tion&#58; No TransactionInterceptor-managed TransactionStatus in scope
at org.springframework.transaction.interceptor.Transa ctionInterceptor.currentTransactionStatus&#40;Transact ionInterceptor.java&#58;67&#41;
at za.co.rmb.spj.deals.domain.DealsHolder.add&#40;DealsHo lder.java&#58;59&#41;
at za.co.rmb.spj.deals.session.JdoDealRepository.doSt ore&#40;JdoDealRepository.java&#58;103&#41;
at za.co.rmb.spj.deals.session.JdoDealRepository.stor e&#40;JdoDealRepository.java&#58;99&#41;
at za.co.rmb.spj.deals.session.StoreTask.execute&#40;Stor eTask.java&#58;29&#41;

Does anybody have any idea why there is no transaction being propogated through to the code?