title: Unable to access proxy object in Spring AOP
body: <p>This issue might be kind of simple but I just can't find the solution.
  I'm using Spring AOP and currently I'm only trying to acquire a reference to a proxy object created by the framework itself. 
  I followed the instructions provided by <a href="https://stackoverflow.com/questions/7482666/get-aop-proxy-from-the-object-itself">this</a> thread, but I'm still getting the following exception:</p>
  
  <p>Exception in thread "main" java.lang.IllegalStateException: Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available.</p>
  
  <p>Here's the required entry in my springContext.xml:</p>
  
  <pre><code> &lt;aop:aspectj-autoproxy expose-proxy="true"/&gt;
  </code></pre>
  
  <p>This is my aspect definition:</p>
  
  <pre><code>@Aspect
  public class DynamicAspect {
  
  
  @Pointcut("execution(* addition.aop.Actor.play(..))")
  public void play() {
  
  }
  
  @Before("play()")
  public void directorGivesInstructions() {
      System.out.println("Director: Light, camera, action!");
  }
  </code></pre>
  
  <p>The main-method where everything gets tested:</p>
  
  <pre><code>public static void main(String[] args) {    
   ApplicationContext context = new ClassPathXmlApplicationContext(...);
   Actor actor = (Actor) context.getBean("actor");
   actor.play();
  }
  </code></pre>
  
  <p>This is the method in the Actor class that raises the exception:</p>
  
  <pre><code> public void play() {
      AopContext.currentProxy();
      System.out.println("Actor starts playing his role...");
  }
  </code></pre>
  
  <p>The aspect is weaved in and called properly.</p>
  
  <p>Thank you very much!</p>