Spring @Controller and Transactionmanager

I have a spring base controller

package org.foo; @Controller public class HelloWorldController implements IHelloWorldController { @RequestMapping(value = "/b/c/", method = RequestMethod.GET) public void doCriticalStuff(HttpServletRequest request, HttpServletResponse response){ //... } } 

Tested via curl -X GET http://myIP:myPort/b/c/ Which works great.

If I configure transaction management through

 <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="helloWorldPC" expression="execution(* org.foo.IHelloWorldController.*(..)) &amp;&amp; !execution(* java.lang.Object.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="helloWorldPC" /> </aop:config> 

Display does not work. I get a 404 error on the client side on the server. The method is not entered. Running a JUnit test with a breakpoint in doCriticalStuff I see AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: ... so the transaction configuration is used.

But the display no longer works. Any ideas?

I am using Spring 3.0.2.RELEASE

+1
source share
1 answer

The transactional aspect is applied using a dynamic proxy , and it does not allow Spring MVC to access @RequestMapping annotations in the target class. You can use <aop:config proxy-target-class="true"> as a workaround.

Command

Spring says they did not fix this behavior for performance reasons (see SPR-5084 comment )

+4
source

All Articles