Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Problem registering service
Problem registering service [message #676965] Tue, 07 June 2011 06:26 Go to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Hello.

I am trying to register this OSGi service via Spring DM:
<bean id="bundleInspector"   class="com.iggroup.administrator.business.internal.BundleInspector">
      <property name="bundleContext" ref="bundleContext" />
</bean>

<osgi:service id="bundleInspector" ref="bundleInspector"
      interface="com.iggroup.administrator.api.business.BundleService"/>

where BundleInspector implements BundleService.

However I get the exception below. Any idea what I may be doing wrong?

TIA,
B.
[2011-06-07 07:13:23.291] region-dm-3                  <AG0000E> Application context creation failure for bundle 'com.iggroup.administrator.business' version '0.0.1.SNAPSHOT'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bundleInspector': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Exported service object does not implement the given interface: interface org.osgi.framework.ServiceRegistration is not assignable to interface com.iggroup.administrator.api.business.BundleService
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: Exported service object does not implement the given interface: interface org.osgi.framework.ServiceRegistration is not assignable to interface com.iggroup.administrator.api.business.BundleService
	at org.springframework.util.Assert.isAssignable(Assert.java:368)
	at org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean.afterPropertiesSet(OsgiServiceFactoryBean.java:197)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
	... 17 common frames omitted

Re: Problem registering service [message #676988 is a reply to message #676965] Tue, 07 June 2011 08:05 Go to previous messageGo to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Found my problem (I need to sleep more... Sad

I was using the "id" attribute in the <osgi:service> element, which is wrong. Removing that attribute fixed my issues -- cryptic exception though!
Re: Problem registering service [message #677149 is a reply to message #676965] Tue, 07 June 2011 17:54 Go to previous messageGo to next message
Costin Leau is currently offline Costin LeauFriend
Messages: 45
Registered: February 2010
Member
The problem comes from the fact that the service references itself (this can work in advanced cases where a bean is OSGi aware and simply wants to publishes itself (for example for service factories)). However this is not the case and since both beans use the same name (the service and the bean) the last one to be read (the service) overrides the former. And since the interface is not a ServiceReference (required to export a service), the "cryptic" exception is being thrown.
Re: Problem registering service [message #678801 is a reply to message #677149] Thu, 09 June 2011 14:45 Go to previous message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Thanks Costin, your explanation makes it all clear now.
Previous Topic:Virgo 3.0 plan date
Next Topic:Build Virgo Kernel 3.0.0.M05 testing with a bundle
Goto Forum:
  


Current Time: Fri Apr 26 19:39:45 GMT 2024

Powered by FUDForum. Page generated in 0.02948 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top