Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » ClassCastException when accessing reference-list ServiceReference
ClassCastException when accessing reference-list ServiceReference [message #1029403] Fri, 29 March 2013 16:32
Kristian Marinkovic is currently offline Kristian Marinkovic
Messages: 2
Registered: February 2013
Junior Member
hi,

if i define a bind-method with a signature that contains a ServiceReference i'm getting a ClassCastException when accessing it with the stack trace below. If i use the service type in the bind-method signature everything works fine. I even tried setting member-type="service-reference" with no success.

I need the ServiceReference because i want to update the service properties of that service. Maybe there is another way to achieve this using blueprint.

Is this a bug or am i missing something? I'm deloying my bundles with a plan on virgo 3.6.0.

g,
kris

	<reference-list id="barrierAdapterList" interface="com.capricube.tmcs.device.api.adapters.BarrierAdapter" availability="optional">
		<reference-listener bind-method="registerBarrierAdapter" unbind-method="unregisterBarrierAdapter" ref="barrierFacade" />
	</reference-list>	


    public void registerBarrierAdapter(ServiceReference barrierAdapterReference) {
        final Object idProperty = barrierAdapterReference.getProperty(DeviceMappingConstants.DEVICE_ID);

        final UUID id = UUID.fromString((String) idProperty);

        final BundleContext context = barrierAdapterReference.getBundle().getBundleContext();

        // FIXME throws exception as it is another type
        final BarrierAdapter barrierFacadeService = (BarrierAdapter) context.getService(barrierAdapterReference);

        barrierAdapterMap.putIfAbsent(id, barrierFacadeService);
    }


Quote:

2013-03-29 17:11:34.805] WARN region-dm-9 o.e.g.b.c.internal.adapter.OsgiServiceLifecycleListenerAdapter custom method [public void com.capricube.tmcs.device.internal.barrier.BarrierFacade.registerBarrierAdapter(org.osgi.framework.ServiceReference)] threw exception when passing service [$Proxy156@65a04633] java.lang.ClassCastException: org.eclipse.gemini.blueprint.service.importer.support.internal.aop.StaticServiceReferenceProxy cannot be cast to org.eclipse.osgi.internal.serviceregistry.ServiceReferenceImpl

at org.eclipse.osgi.framework.internal.core.BundleContextImpl.getService(BundleContextImpl.java:594)

at com.capricube.tmcs.device.internal.barrier.BarrierFacade.registerBarrierAdapter(BarrierFacade.java:39)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:601)

at org.eclipse.gemini.blueprint.util.internal.ReflectionUtils.invokeMethod(ReflectionUtils.java:106)

at org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter.invokeCustomServiceReferenceMethod(OsgiServiceLifecycleListenerAdapter.java:209)

at org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter.bind(OsgiServiceLifecycleListenerAdapter.java:271)

at org.eclipse.gemini.blueprint.service.importer.support.internal.util.OsgiServiceBindingUtils.callListenersBind(OsgiServiceBindingUtils.java:46)

at org.eclipse.gemini.blueprint.service.importer.support.internal.collection.OsgiServiceCollection$BaseListener.serviceChanged(OsgiServiceCollection.java:93)

at org.eclipse.gemini.blueprint.util.OsgiListenerUtils.dispatchServiceRegistrationEvents(OsgiListenerUtils.java:111)

at org.eclipse.gemini.blueprint.util.OsgiListenerUtils.addServiceListener(OsgiListenerUtils.java:88)

at org.eclipse.gemini.blueprint.util.OsgiListenerUtils.addServiceListener(OsgiListenerUtils.java:60)

at org.eclipse.gemini.blueprint.service.importer.support.internal.collection.OsgiServiceCollection.afterPropertiesSet(OsgiServiceCollection.java:324)

at org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceCollectionProxyFactoryBean$1.run(OsgiServiceCollectionProxyFactoryBean.java:211)

at org.eclipse.gemini.blueprint.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean.java:103)

at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)

at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)

at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1446)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:249)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:622)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)

at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)

at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)

at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)

at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)

at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)

at org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

at java.lang.Thread.run(Thread.java:722)


Previous Topic:ClassCastException when using reference-list ServiceReference
Next Topic:Maven repository for Gemini projects
Goto Forum:
  


Current Time: Tue Oct 21 00:30:49 GMT 2014

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

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