title: Using tx:annotation-driven prevents Autowiring a bean
body: <p>I'm developing a module on an OSGi application, using Spring MVC and Virgo Webserver.</p>
  
  <p>On my module I have a Controller, that access a Manager, which has a list of handlers that are responsible for handling report generation.</p>
  
  <p>Everything was doing fine until I had to call a transactional method from an external service. Since none of my classes were transactional I had to add the references to the transation manager and <code>annotation-driven</code>. Then, my Manager stopped being notified.</p>
  
  <p>I understand that when using <code>annotation-driven</code> all my beans must implement a public interface in order for the proxying mechanism to work. And as far as I know, all the classes are (one of them wasn't, but then I changed it).</p>
  
  <p>My configuration files are:</p>
  
  <p>bundle-context.xml:
  </p>
  
  <pre><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:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context" 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/aop http://www.springframework.org/schema/aop/spring-aop-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/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt;
  &lt;context:annotation-config /&gt;
  &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  &lt;bean id="reportManager" class="reportmodule.manager.impl.ReportManagerImpl"/&gt;
  &lt;bean id="mvpepReportHandler" class="reportmodule.manager.impl.MVPEPReportHandler"/&gt;
  &lt;bean id="reportConfigDao" class="reportmodule.repository.impl.ReportConfigurationHibernateDAOImpl"/&gt;
  &lt;bean id="oSGIChangeReportHandler" class="reportmodule.osgi.impl.OSGIChangeReportHandlerImpl"/&gt;
  &lt;bean id="reportController"
  class="reportmodule.controller.impl.ReportControllerImpl"/&gt;
  &lt;bean id="reportControllerHandlerMapping"
  class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
  &lt;property name="mappings"&gt;
  &lt;value&gt;/module/reportController/**=reportController&lt;/value&gt;
  &lt;/property&gt;
  &lt;property name="alwaysUseFullPath" value="true"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>and my bundle-osgi.xml is as follows:
  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:osgi="http://www.springframework.org/schema/osgi"
  xmlns:osgi-compendium="http://www.springframework.org/schema/osgi-compendium"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/osgi
  http://www.springframework.org/schema/osgi/spring-osgi.xsd
  http://www.springframework.org/schema/osgi-compendium
  http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium-1.2.xsd"&gt;
  
  &lt;osgi:reference id="transactionManager" interface="org.springframework.transaction.PlatformTransactionManager" /&gt;
  &lt;osgi:reference id="sessionFactory" interface="org.hibernate.SessionFactory" /&gt;
  &lt;osgi:reference id="smaCoreUtilService" interface="core.util.service.SmaCoreUtilService" /&gt;
  
  &lt;osgi:service ref="reportControllerHandlerMapping"
  interface="org.springframework.web.servlet.HandlerMapping"
  context-class-loader="service-provider"
  auto-export="interfaces"/&gt;
  
  &lt;osgi:service interface="reportmodule.api.manager.ReportManager" ref="reportManager" auto-export="interfaces"/&gt;
  
  &lt;osgi:service interface="reportmodule.api.manager.ReportHandler" ref="mvpepReportHandler" auto-export="interfaces"/&gt;
  
  &lt;osgi:service interface="reportmodule.repository.ReportConfigurationDAO" ref="reportConfigDao" auto-export="interfaces"/&gt;
  
  &lt;osgi:service interface="reportmodule.osgi.OSGIChangeReportHandler" ref="oSGIChangeReportHandler" auto-export="interfaces"/&gt;
  
  &lt;osgi:list cardinality="0..N" id="reportHandler" interface="reportmodule.api.manager.ReportHandler" greedy-proxying="true"&gt;
  &lt;osgi:listener ref="oSGIChangeReportHandler" bind-method="register" unbind-method="unregister"/&gt;    
  &lt;/osgi:list&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>So, after all the services are being published the oSGIChangeReportHandler.register is called (I'm able to debbug it):</p>
  
  <pre class="lang-java prettyprint-override"><code>@Service(value="oSGIChangeReportHandler")
  public class OSGIChangeReportHandlerImpl implements OSGIChangeReportHandler {
  
      private ReportManager reportManager;
  
      /**
       * @param reportManager the reportManager to set
       */
      @Autowired
      public void setReportManager(ReportManager reportManager) {
          this.reportManager = reportManager;
      }
  
      @SuppressWarnings("rawtypes")
      public void register(ReportHandler reportHandler, Map properties) {
          reportManager.addReportHandler(reportHandler);
      }
  
      @SuppressWarnings("rawtypes")
      public void unregister(ReportHandler reportHandler, Map properties) {
          reportManager.removeReportHandler(reportHandler);
      }
  
  
  }
  </code></pre>
  
  <p>And although the debugger shows Proxies for both the <code>reportManager</code> and <code>reportHandler</code> on the <code>register</code> method, the debugger does not halts on the <code>ReportManagerImpl.addReportHandler</code> method:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Service(value="reportManager")
  @Transactional(propagation = Propagation.MANDATORY, rollbackFor = Exception.class)
  public class ReportManagerImpl implements ReportManager {
  
      private ReportConfigurationDAO reportConfigurationDAO;
  
      private ArrayList&lt;ReportHandler&gt; reportHandlers = new ArrayList&lt;ReportHandler&gt;();
  
      /**
       * @param reportConfigurationDAO the reportConfigurationDAO to set
       */
      @Autowired
      public void setReportConfigurationDAO(ReportConfigurationDAO reportConfigurationDAO) {
          this.reportConfigurationDAO = reportConfigurationDAO;
      }
  
      @Override
      @Transactional
      public InputStream gerarRelatorio(ReportRequest repoReq) throws NegocioException {
          // Generates the report...
      }
  
      /* (non-Javadoc)
       * @see reportmodule.api.manager.ReportManager#addReportHandler(reportmodule.api.manager.ReportHandler)
       */
      @Override
      public void addReportHandler(ReportHandler handler) {
          if (handler != null) {
              this.reportHandlers.add(handler);
          }
      }
  
      /* (non-Javadoc)
       * @see reportmodule.api.manager.ReportManager#removeReportHandler(reportmodule.api.manager.ReportHandler)
       */
      @Override
      public void removeReportHandler(ReportHandler handler) {
          if (handler != null) {
              this.reportHandlers.remove(handler);
          }
      }
  
  }
  </code></pre>
  
  <p>I must stress that when I remove the <code>tx:annotation-driven</code> tag from the <code>bundle-context.xml</code> file, everything works fine (the <code>handler</code> is properly added to the list during startup).</p>
  
  <p>So, what am I missing here?</p>