title: Spring Expression Language and Spring Security 3: accessing bean reference in @PreAuthorize
body: <p>I'm trying to access a bean reference in a @PreAuthorize annotation as follows:</p>
  
  <pre><code>@PreAuthorize("@testBean.getTestValue()")
  public String testSpEL() {
      ....
  }
  </code></pre>
  
  <p>I have a test bean configured as follows:</p>
  
  <pre><code>@Component(value="testBean")
  public class TestBean {
      public boolean getTestValue() {
          return true;
      }
  }
  </code></pre>
  
  <p>When I try to access the testSpEL() method however, I'm confronted with the following exception:</p>
  
  <pre><code>Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): No bean resolver registered in the context to resolve access to bean 'testBean'
      at org.springframework.expression.spel.ast.BeanReference.getValueInternal(BeanReference.java:45)
      at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52)
      at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
      at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:97)
      at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:11)
  </code></pre>
  
  <p>I have thoroughly done my research but I can't find anywhere what I need to change in my configuration to get this to work. Any pointers?</p>
  
  <p>Thanks!</p>
  
  <p>Kind regards, Jonck</p>
  
  <p>P.S. I'm using Spring 3.0.5. The following seems to indicate this type of functionality should work:</p>
  
  <p><a href="https://jira.springsource.org/browse/SPR-7173" rel="noreferrer">https://jira.springsource.org/browse/SPR-7173</a></p>