title: Spring 3 MVC @Controller with AOP interceptors?
body: <p>Anyone knows why apparently it is not possible to use AOP with annotated MVC Controllers? (see <a href="https://stackoverflow.com/questions/5305938/implement-aop-for-controllers-in-spring-3">Post</a>).
  I have a @Controller that stops working as soon as I add a pointcut to it.
  The problem is not that the interceptor is not being called, but rather the @Controller simply stops working (in the log you can see that instead of "Mapped URL path [/xx] onto handler 'Yyy'" you get a "no URL paths identified").</p>
  
  <p>I know there is a mechanism for adding interceptors to controllers via the handlerMapping but my question is specific to AOP interceptors. Aren't annotated controllers just pojos in the Spring container as any other pojo?  What is the difference? Why?</p>
  
  <pre><code>@Controller
  @RequestMapping("/user")
  public class RestTestImpl implements RestTest {
      @RequestMapping(value="/", method={RequestMethod.GET})
      public @ResponseBody String deleteUsers(String arg) {
          return "Xxxxx";
      }
  }
  </code></pre>
  
  <p>In my servlet-Context I have:</p>
  
  <pre><code>&lt;context:component-scan base-package="org.xxx.yyy"&gt;&lt;/context:component-scan&gt;
  &lt;mvc:annotation-driven /&gt;
  &lt;bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt;
      . . .
  &lt;/bean&gt;
  </code></pre>
  
  <p>And everything works just great.</p>
  
  <p>But when I add:</p>
  
  <pre><code>    &lt;aop:config&gt;
          &lt;aop:pointcut expression="execution(* org.xxx.*(..))" id="pc1"/&gt;
          &lt;aop:advisor advice-ref="hibernateInterceptor"  pointcut-ref="pc1" order="2" /&gt;
      &lt;/aop:config&gt;
  </code></pre>
  
  <p>The controller stops being a controller (no errors, simply it stops binding to the specified URL)!</p>