Announcement Announcement Module
Collapse
No announcement yet.
Commons attributes transactions and aop:config Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Commons attributes transactions and aop:config

    Hi,

    I have defined the following configuration for transaction declarations using commons attributes:

    Code:
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    	
    	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    	
    	<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
    	
    	<bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
    		<property name="transactionInterceptor" ref="transactionInterceptor"/>
    	</bean>
    
    	<bean id="transactionInterceptor"
    			class="org.springframework.transaction.interceptor.TransactionInterceptor">
    		<property name="transactionManager" ref="transactionManager"/>
    		<property name="transactionAttributeSource">
    			<bean class="org.springframework.transaction.interceptor.AttributesTransactionAttributeSource">
    				<property name="attributes" ref="attributes"/>
    			</bean>
    		</property>
    	</bean>
    	
    	<bean id="attributes" class="org.springframework.metadata.commons.CommonsAttributes"/>
    I have then tried to add the aspect for the method that is already marked for transactions using the commons attributes:

    Code:
    <bean id="logger" class="xxx.yyy.zzz.log.LoggerImpl" />
    <aop:config proxy-target-class="true">
    	<aop:aspect ref="logger">
    		<aop:pointcut id="activatePointcut" expression="execution(* xxx.yyy.zzz.MyManager.activate(..))" />
    		<aop:after-returning pointcut-ref="activatePointcut" method="logRequest" />
    	</aop:aspect>
    </aop:config>
    However, I'm getting the following exception:

    Code:
    java.lang.IllegalStateException: No MethodInvocation found: Check that an AOP invocation is in progress, and that the ExposeInvocationInterceptor is in the interceptor chain.
    	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.currentInvocation(ExposeInvocationInterceptor.java:72)
    	at org.springframework.aop.aspectj.AbstractAspectJAdvice.getJoinPointMatch(AbstractAspectJAdvice.java:599)
    	at org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:54)
    	at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:51)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy1.activate(Unknown Source)
    	at xxx.yyy.zzz.MyManagerTest.testRequest(MyManagerTest.java:97)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    The code is executed from within a test that extends AbstractTransactionalDataSourceSpringContextTests.

    Can anyone help me with this issue?

    Best Regards
Working...
X