开发者

Spring @Controller and Transactionmanager

I'm having a basic Spring Controller

package org.foo;

@Controller
public class HelloWorldController implements IHelloWorldController
{
   @RequestMapping(value = "/b/c/", method = RequestMethod.GET)
   public void doCriticalStuff(HttpSer开发者_运维知识库vletRequest request, HttpServletResponse response){
      //...
   }
}

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

If I'm configuring transaction Management via

<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>

The mapping is not working any longer. I get a 404 Error on client side an on Server the Method is not entered. Doing a JUnit test with a breakpoint in doCriticalStuff I can see AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: ... so the transaction config is used.

But the mapping is not working any longer. Any ideas?

I'm using Spring 3.0.2.RELEASE


Transactional aspect is applied using dynamic proxy, and it prevents Spring MVC from accessing the @RequestMapping annotations on the target class. You may use <aop:config proxy-target-class="true"> as a workaround.

Spring team says that they wouldn't fix this behaviour for efficiency reasons (see comment on SPR-5084)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜