title: OSGi Service references not working with constructor injection
body: <p>I've got a bundle (A) that exports a Hibernate transaction manager as an OSGi service, with a service interface of <code>PlatformTransactionManager</code>.</p>
  
  <p>In another bundle (B) I define a reference to that OSGi service.  Bundle B defines a bean, <code>ReservationDao</code>, that takes the <code>PlatformTransactionManager</code> as a constructor parameter.  The constructor is marked with <code>@Autowired</code>.</p>
  
  <p>When the application context loads, the following error is <strong>sometimes (often)</strong> thrown:</p>
  
  <pre><code>Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.transaction.PlatformTransactionManager]: : No matching bean of type [org.springframework.transaction.PlatformTransactionManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.transaction.PlatformTransactionManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:513)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
  ... 20 more
  </code></pre>
  
  <p>Basically, autowiring fails because there's no bean available that is a <code>PlatformTransactionManager</code>.  The same error occurs for field injection.</p>
  
  <p>If I create setter methods and mark those with <code>@Autowire</code>, the application context loads correctly.</p>
  
  <p>Can anyone explain why constructor and field autowiring might fail, but setter autowiring always succeeds?  Is there any way to define the OSGi references in such a way that all autowiring works?  I'd hate to refactor code around a limitation of a framework.</p>