title: Using @Transaction annotation with @Autowired - Spring
body: <p>Well, i have a Class with @Service annotation and some strange occurrs: When i put the annotation @Transaction in some method i can't start tomcat server, i got error: "Can not autowired..." in another class when i use my @Autowired, but when i remove the @Transaction all works fine.</p>
  
  <p>My class header is:</p>
  
  <pre><code>@Service(value = "caixaBO")
  public class CaixaBOImpl extends BasicBOImpl {
  </code></pre>
  
  <p>And my method signature is:</p>
  
  <pre><code>@Transactional(propagation = Propagation.REQUIRED)
  public void movimentarCaixaPaciente(String descricao, double valor,
          Paciente paciente) {
  </code></pre>
  
  <p>When i use @Autowired CaixaBOImpl caixaBO, i got error in tomcat initialized because the annotation @Transaction.</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>1 - I have transactionManager in applicationContext.xml, look:</p>
  
  <pre><code>&lt;!-- Configuracao do gerente de transacoes do Spring --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>2 - I have CGLIB in pom.xml, look:</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;cglib&lt;/groupId&gt;
              &lt;artifactId&gt;cglib-nodep&lt;/artifactId&gt;
              &lt;version&gt;2.2.2&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>My stack trace:</p>
  
  <pre><code>Grave: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pedidoProteseBO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.odontonew.financeiro.bo.CaixaBOImpl br.com.odontonew.odonto.bo.PedidoProteseBOImpl.caixaBO; nested exception is java.lang.IllegalArgumentException: Can not set br.com.odontonew.financeiro.bo.CaixaBOImpl field br.com.odontonew.odonto.bo.PedidoProteseBOImpl.caixaBO to com.sun.proxy.$Proxy36
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:724)
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.odontonew.financeiro.bo.CaixaBOImpl br.com.odontonew.odonto.bo.PedidoProteseBOImpl.caixaBO; nested exception is java.lang.IllegalArgumentException: Can not set br.com.odontonew.financeiro.bo.CaixaBOImpl field br.com.odontonew.odonto.bo.PedidoProteseBOImpl.caixaBO to com.sun.proxy.$Proxy36
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
      ... 20 more
  Caused by: java.lang.IllegalArgumentException: Can not set br.com.odontonew.financeiro.bo.CaixaBOImpl field br.com.odontonew.odonto.bo.PedidoProteseBOImpl.caixaBO to com.sun.proxy.$Proxy36
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
      at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
      at java.lang.reflect.Field.set(Field.java:741)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:504)
      ... 22 more
  </code></pre>