title: How do I use a Spring Service method in a Spring Security expression?
body: <p>I have a spring Service and want to use a method in the service combined with the current user in a spring security expression. I saw <a href="https://stackoverflow.com/questions/5743565/spring-expression-language-and-spring-security-3-accessing-bean-reference-in-p" title="here">another question on stackoverflow</a> that led me to believe something like this was possible. I'm using spring 3.1.2.</p>
  
  <pre><code>@Service("orgService")
  public class DefaultOrganizationService implements OrganizationService {
      @Override
      @Transactional
      public boolean isOrgAdmin(String username) 
      {   
         return true;
      }
  }
  </code></pre>
  
  <p>Then in a jsp, I have something like this:</p>
  
  <pre><code>&lt;sec:authorize access="orgService.isOrgAdmin(principal.name)"&gt;
      USER IS ORG ADMIN
  &lt;/sec:authorize&gt;
  </code></pre>
  
  <p>However, when I run my web app with this setup, I get</p>
  
  <pre><code>org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'orgService' cannot be found on object of type 'org.springframework.security.web.access.expression.WebSecurityExpressionRoot'
  </code></pre>
  
  <p>I've tried expressions with both "@orgService..." and "orgService..."</p>
  
  <p>Is what I'm trying to do possible, or do I need to implement a <a href="http://blog.solidcraft.eu/2011/03/spring-security-by-example-securing.html" rel="nofollow noreferrer">PermissionEvaluator</a>?</p>