title: Spring AOP proxy doesn't work as expected
body: <p>Actually I'am confused about the behavior of spring proxies. I think I know the main difference between the proxy mechanisms of j2ee, cglib and aspectj. I have the aspectj auto proxy enabled in my configuration class and aspectj is included in the class path.</p>
  
  <p>My configuration</p>
  
  <pre><code>@Configuration
  @EnableAspectJAutoProxy(proxyTargetClass = true)
  public class ApplicationConfiguration {
      ...
  }
  </code></pre>
  
  <p>AspectJ dependency</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
      &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
      &lt;version&gt;1.8.5&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>By using this simple setup I've assumed that the bean injection work as intended. But instead my application results in <code>IllegalArgumentException</code>s with messages like "Can not set [...] field [...] to com.sun.proxy.$Proxy30". That means spring uses the j2ee proxy for my service, even with aspectj proxy enabled.</p>
  
  <p>Finally i've figured out that the interfaces on my service causes this behavior. It seems that spring decides to use the j2ee proxy when my service implements any interface. If I remove them, it works.</p>
  
  <p>Failure:</p>
  
  <pre><code>@Service
  @Validated
  public class MyService implements Interface1, Interface2 {
  
      @override
      public void methodFromInterface1() {
      }
  
      @override
      public void methodFromInterface2() {
      }
  
      public void serviceMethod() {
      }
  }
  </code></pre>
  
  <p>OK:</p>
  
  <pre><code>@Service
  @Validated
  public class MyService {
  
      public void methodFromInterface1() {
      }
  
      public void methodFromInterface2() {
      }
  
      public void serviceMethod() {
      }
  }
  </code></pre>
  
  <p>Until now I've understand that interfaces are required for the j2ee proxy. But it's new for me, that a cglib/aspectj proxy doesn't work with beans that implements interfaces. </p>
  
  <p>Is there a way to...</p>
  
  <p>... force spring to not use j2ee proxies?</p>
  
  <p>... force spring to use cglib/aspectj proxies (even for classes that have interfaces)?</p>
  
  <p>Is that a bug or desired behavior of spring?</p>
  
  <p><strong>Edit</strong>: Example updated, <code>@Transational</code> replaced by <code>@Validated</code></p>
  
  <p><strong>Edit2: Solution:</strong> <code>@Validated</code> is affected by the <code>MethodValidationPostProcessor</code>. So the property <code>proxyTargetClass</code> has to be set to <code>true</code> for this bean.</p>
  
  <pre><code>@Bean
  public MethodValidationPostProcessor methodValidationPostProcessor() {
      final MethodValidationPostProcessor methodValidationPostProcessor;
      methodValidationPostProcessor = new MethodValidationPostProcessor();
      methodValidationPostProcessor.setProxyTargetClass(true);
      return methodValidationPostProcessor;
  }
  </code></pre>