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: No TransactionInterceptor-managed TransactionStatus in scope
at org.springframework.transaction.interceptor.Transa ctionInterceptor.currentTransactionStatus(Transact ionInterceptor.java:67)
at za.co.rmb.spj.deals.domain.DealsHolder.add(DealsHo lder.java:59)
at za.co.rmb.spj.deals.session.JdoDealRepository.doSt ore(JdoDealRepository.java:103)
at za.co.rmb.spj.deals.session.JdoDealRepository.stor e(JdoDealRepository.java:99)
at za.co.rmb.spj.deals.session.StoreTask.execute(Stor eTask.java:29)
Does anybody have any idea why there is no transaction being propogated through to the code?
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: No TransactionInterceptor-managed TransactionStatus in scope
at org.springframework.transaction.interceptor.Transa ctionInterceptor.currentTransactionStatus(Transact ionInterceptor.java:67)
at za.co.rmb.spj.deals.domain.DealsHolder.add(DealsHo lder.java:59)
at za.co.rmb.spj.deals.session.JdoDealRepository.doSt ore(JdoDealRepository.java:103)
at za.co.rmb.spj.deals.session.JdoDealRepository.stor e(JdoDealRepository.java:99)
at za.co.rmb.spj.deals.session.StoreTask.execute(Stor eTask.java:29)
Does anybody have any idea why there is no transaction being propogated through to the code?