title: Spring-Security 3/Spring MVC and the dreaded @Secured/RequestMapping
body: <p>i had lots of problems adding Secured annotations to my Controllers.</p>
  
  <p>it turns out letting my Controller implement an InitializingBean was a bad idea.</p>
  
  <pre><code>public class MyController implements InitializingBean {
  
      @Secured(value="ROLE_ADMIN")
      @RequestMapping(method = RequestMethod.GET, value = "/{id}/edit")
      public String getView(Model model, @PathVariable("id") long id) {
          return "some view";
      }
  }
  </code></pre>
  
  <p>this failed with: </p>
  
  <blockquote>
    <p>WARN PageNotFound:962 - No mapping
    found for HTTP request with URI[...]</p>
  </blockquote>
  
  <p>removing the @Secured Annotation would work, but obviously i didn't want to do that.
  after lots of wasted time on the net i noticed the last difference beetween a working and a non working controller was that it implemented the InitializingBean Interface. And now this works like a charm:</p>
  
  <pre><code>public class MyController{
  
      @Secured(value="ROLE_ADMIN")
      @RequestMapping(method = RequestMethod.GET, value = "/{id}/edit")
      public String getView(Model model, @PathVariable("id") long id) {
          return "some view";
      }
  }
  </code></pre>
  
  <p>Can anyone help me understand that behaviour?</p>