Hello,
I am having a problem with Spring 3.1.2.RELEASE and it looks like it may be a bug. I tried to debug it, but it's just getting too deep into the Spring AOP proxy code for me to understand, so I'd appreciate some advice.
Everything works correctly before the context refresh, but after strange things happen.
Here is the relevant declarations:
I have observed the instantiation of two TransactionInterceptors with the corresponding HibernateTransactionManager for each advice when the program starts:PHP Code:<aop:config proxy-target-class="true">
<!-- Trace logging -->
<aop:advisor pointcut="ca.gc.agr.agrirecovery.SystemArchitecture.businessService()" advice-ref="serviceTraceLoggingAdvice" order="1" />
<!-- Transaction Management -->
<aop:advisor pointcut="ca.gc.agr.agrirecovery.SystemArchitecture.businessService()" advice-ref="txAdvice" order="2"/>
<!-- Ref Data Transaction Management -->
<aop:advisor pointcut="ca.gc.agr.agrirecovery.SystemArchitecture.referenceDataManagement()" advice-ref="refDataTxAdvice" order="3"/>
</aop:config>
<!--
Transaction advice definition, based on method name patterns. Defaults to PROPAGATION_REQUIRED.
-->
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
<tx:method name="find*" propagation="REQUIRED" read-only="true"/>
<tx:method name="validate*" propagation="REQUIRED" read-only="true"/>
<tx:method name="is*" propagation="REQUIRED" read-only="true"/>
<tx:method name="calculate*" propagation="REQUIRED" read-only="true"/>
<tx:method name="setup*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
<tx:advice id="refDataTxAdvice">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>
After the refresh I can see two new TransactionInterceptors beeing created. Here they are:Code:org.springframework.transaction.interceptor.TransactionInterceptor@121157c9, id=125 <- txAdvice org.springframework.orm.hibernate4.HibernateTransactionManager@7fad61d3, id=112 org.springframework.transaction.interceptor.TransactionInterceptor@b89b904, id=193 <- refDataTxAdvice org.springframework.orm.hibernate4.HibernateTransactionManager@7fad61d3, id=112
ok, two new TransactionInterceptors with one new HibernateTransactionManager. So far so good.Code:org.springframework.transaction.interceptor.TransactionInterceptor@6d441cce, id=334 org.springframework.orm.hibernate4.HibernateTransactionManager@2fca61f9, id=335 org.springframework.transaction.interceptor.TransactionInterceptor@6feb2ae7, id=492 org.springframework.orm.hibernate4.HibernateTransactionManager@2fca61f9, id=335
However, the next request after the refresh uses the following TransactionInterceptors:
Note that txAdvice is being serviced by the wrong TransactionInterceptor! It is using the pre-refresh one, so HibernateTransactionManager in it is no longer valid.Code:org.springframework.transaction.interceptor.TransactionInterceptor@121157c9, id=125 org.springframework.orm.hibernate4.HibernateTransactionManager@7fad61d3, id=112 org.springframework.transaction.interceptor.TransactionInterceptor@6feb2ae7, 492 org.springframework.orm.hibernate4.HibernateTransactionManager@2fca61f9, id=335
As a result, everything that goes through refDataTxAdvice works, but calls that are advised by txAdvice fail.
So my questions is this - how/why is Spring using an old TransactionInterceptor, even though it has correctly created two new ones? Is this a bug?
Any ideas would be appreciated.
Thanks.


Reply With Quote
