Results 1 to 4 of 4

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

  1. #1
    Join Date
    Apr 2010
    Posts
    2

    Default 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. #2
    Join Date
    Apr 2010
    Posts
    2

    Default

    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)

  3. #3
    Join Date
    Oct 2008
    Location
    Winchester, UK
    Posts
    535

    Default

    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).
    Glyn Normington
    SpringSource

  4. #4
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    With Lists you should try @Resource. @Autowired has issues with generified lists.
    Thanks
    Dmitry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •