Announcement Announcement Module
Collapse
No announcement yet.
referencing a collection of service doesn't work in spring dm server 2.0.1.RELEASE Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • referencing a collection of service doesn't work in spring dm server 2.0.1.RELEASE

    First,I deploy a bundle A which exports two services with the same interface,like this
    Code:
        <service ref="provider1" interface="x.y.z.provider.IXmlparseProvider" />
        <service ref="provider2" interface="x.y.z.provider.IXmlparseProvider" />
    Second,I deploy a web bundle B which references a collection of the service above,like this
    Code:
     	<list id="xmlparseProviders" interface="x.y.z.provider.IXmlparseProvider" />
    Third,I autowire the list service into class in web bundle B,like this
    Code:
            @Autowired
    	private List<IXmlparseProvider> xmlparseProviders;
    Then, an error occur when starting spring dm server:
    Code:
    org.springframework.osgi.service.ServiceUnavailableException: service matching filter=[(objectClass=x.y.z.provider.IXmlparseProvider)] unavailable
    	at org.springframework.osgi.service.importer.support.internal.collection.OsgiServiceCollection.mandatoryServiceCheck(OsgiServiceCollection.java:318)
    	at org.springframework.osgi.service.importer.support.internal.collection.OsgiServiceCollection.afterPropertiesSet(OsgiServiceCollection.java:282)
    	at org.springframework.osgi.service.importer.support.OsgiServiceCollectionProxyFactoryBean.createProxy(OsgiServiceCollectionProxyFactoryBean.java:240)
    	at org.springframework.osgi.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean.java:86)
    	at org.springframework.osgi.service.importer.support.OsgiServiceCollectionProxyFactoryBean.getObject(OsgiServiceCollectionProxyFactoryBean.java:188)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:143)
    	... 32 common frames omitted
    Web bundle B doesn't reference the two services exported by bundle A as a list collection.
    What's the matter? Is there something wrong with my code?
    I am very confused with this issue;can somebody give me some ideas?

  • #2
    if I add cardinality attribute like this:
    Code:
        <list id="xmlparseProviders" interface="x.y.z.provider.IXmlparseProvider" cardinality="0..N" />
    The dm server can start normally. An error occur still when I browing the web bundle's page.
    Code:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [x.y.z.provider.IXmlparseProvider] found for dependency [collection of x.y.z.provider.IXmlparseProvider]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:896)

    Comment


    • #3
      I would like to understand where your bundles are getting the x.y.z.provider package from.

      If they are not obtaining this package from the same bundle, then the problem may be that the <service> and the <list> elements are using incompatible types and the list may not be able to "see" the services (because of the way the service registry is partitioned to avoid type incompatibility).

      Comment


      • #4
        With Lists you should try @Resource. @Autowired has issues with generified lists.

        Comment

        Working...
        X