title: Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy13 cannot be cast to CustomeClass
body: <p>I am trying to learn AOP with Spring Framework, but there is one exception that keeps on getting invoked.</p>
  
  <blockquote>
    <p>Error :  Exception in thread "main" java.lang.ClassCastException:
    com.sun.proxy.$Proxy13 cannot be cast to com.controller.Triangle</p>
  </blockquote>
  
  <p><strong>Shape.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>package com.controller;
  
  public interface Shape {
      public void draw();
  }
  </code></pre>
  
  <p><strong>Triangle.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>package com.controller;
  import org.springframework.stereotype.Component;
  
  @Component
  public class Triangle implements Shape
  {
          public void draw()
          { 
                System.out.println("this draw method of triangle"),
          }
  }
  </code></pre>
  
  <p><strong>myCustomAspect.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>    package com.AOP;
  
      import org.aspectj.lang.annotation.After;
      @EnableAspectJAutoProxy
      @Component
      @Aspect
      public class myCustomAspect {
  
          @Pointcut("execution(* *.draw())")
          private void pop(){}
  
          @Before("pop()")
          private void beforeMeth(){
              System.out.println("this is before draw"); }
      }
  </code></pre>
  
  <p><strong>inside main method</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>ApplicationContext  ssp = new ClassPathXmlApplicationContext("/Spring.xml");
  Shape tr=(Triangle)ssp.getBean("triangle");
  tr.draw();
  </code></pre>
  
  <p><strong>Spring.XML</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;?xml version = "1.0" encoding = "UTF-8"?&gt;
        &lt;beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xmlns:context="http://www.springframework.org/schema/context"
           xmlns:aop = "http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-3.0.xsd
              http://www.springframework.org/schema/aop 
              http://www.springframework.org/schema/aop/spring-aop-3.0.xsd "&gt;
  
       &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
      &lt;context:component-scan base-package="com.controller,com.AOP"&gt;&lt;/context:component-scan&gt;
  &lt;/beans&gt; 
  </code></pre>
  
  <p>Please any one help.</p>