title: Caused by: java.lang.ClassCastException: $ProxyX cannot be cast to my.package.DefaultCustomerProviderImpl
body: <p>In my java class I have:</p>
  
  <pre><code>@Autowired
  @Qualifier("customerProviderExec")
  private DefaultCustomerProvider customerProvider;
  </code></pre>
  
  <p>And in my context configuration XML</p>
  
  <pre><code>&lt;bean id="customerProviderExec" class="my.package.DefaultCustomerProviderExecutor"&gt;
      &lt;property name="defaultCustomerProviderService" ref="customerProviderImpl" /&gt;   
  &lt;/bean&gt; 
  
  &lt;bean id="testCustomerProviderImpl" class="my.package.DefaultCustomerProviderTest"&gt;
      &lt;property name="customerProviderImpl" ref="customerProviderImpl" /&gt;
  &lt;/bean&gt;    
  
  &lt;bean id="customerProviderImpl" class="my.package.DefaultCustomerProviderImpl"&gt;
      ...
  &lt;/bean&gt;
  </code></pre>
  
  <p><em>Important</em>: The class DefaultCustomerProviderImpl implements DefaultCustomerProvider </p>
  
  <p>When I try to execute in my Java class:</p>
  
  <pre><code>DefaultCustomerProviderExecutor executor = (DefaultCustomerProviderExecutor)this.getCustomerProvider();
  return (DefaultCustomerProviderImpl) executor.getDefaultCustomerProviderService();      
  </code></pre>
  
  <p>I get the error:</p>
  
  <p>Caused by: java.lang.ClassCastException: $Proxy17 cannot be cast to my.package.DefaultCustomerProviderImpl</p>
  
  <p>Has someone been throug this?</p>