views:

46

answers:

1

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

+3  A: 

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)

axtavt
ok, i wrote added <aop:config proxy-target-class="true"> instead of <aop:config> and included cglib Version 2.2 now i get "Unable to install breakpoint due to missing line number attributes" tried http://solveme.wordpress.com/2008/08/27/unable-to-install-breakpoint-due-to-missing-line-number-attributes/ doesn't help so far. I'm using m2Eclipse Version 0.10.0.20100209-0800 maybe thats an issue?
Martin Dürrmeier
apart from the breakpoint message i see the following call stackMethodProxy.invoke(Object, Object[])Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint() Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() TransactionInterceptor.invoke(MethodInvocation)Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() ExposeInvocationInterceptor.invoke(MethodInvocation)Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed()Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Object, Method, Object[], MethodProxy)Proxy AOP Proxy is used
Martin Dürrmeier
@axtavt Thank you!
Martin Dürrmeier