Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 402255

Summary: java.lang.reflect.MalformedParameterizedTypeException using reference-listener
Product: [RT] Gemini.Blueprint Reporter: Matt Magoffin <eclipse.org>
Component: CoreAssignee: Project Inbox <gemini.blueprint-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: aaronjwhiteside, eclipse.org, glyn.normington, matt, olaf
Version: 1.0.2.RELEASEKeywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Example blueprint bundle none

Description Matt Magoffin CLA 2013-03-03 18:31:17 EST
Created attachment 227859 [details]
Example blueprint bundle

I'm upgrading a system from Spring DM 1.2 to Gemini Blueprint, and came across an issue where a java.lang.reflect.MalformedParameterizedTypeException was thrown for some of my configured reference listeners, running in OSGi R5.

It seemed to come down to the method signature of the listener itself, e.g. this throws the exception:

public void onBind(ServiceReference<?> ref) {}

while this does not:

public void onBind(ServiceReference ref) {}

The associated Blueprint XML is:

<reference-listener ref="listener" bind-method="onBind" unbind-method="onUnbind"/>

I've attached a small sample bundle that demonstrates the issue (I'm deploying into Equinox 3.8.1).
Comment 1 Matt Magoffin CLA 2013-03-03 18:32:02 EST
The resulting stack trace is:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listener' defined in OSGi resource[bundleentry://39.fwk2076812930/OSGI-INF/blueprint/module.xml|bnd.id=39|bnd.sym=reified-test]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter.retrieveTarget(OsgiServiceLifecycleListenerAdapter.java:96)
	at org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter.unbind(OsgiServiceLifecycleListenerAdapter.java:278)
	at org.eclipse.gemini.blueprint.service.importer.support.internal.util.OsgiServiceBindingUtils.callListenersUnbind(OsgiServiceBindingUtils.java:67)
	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceDynamicInterceptor.afterPropertiesSet(ServiceDynamicInterceptor.java:472)
	at org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceProxyFactoryBean$2.run(OsgiServiceProxyFactoryBean.java:196)
	at org.eclipse.gemini.blueprint.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean.java:103)
	at org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceProxyFactoryBean.getObject(OsgiServiceProxyFactoryBean.java:125)
	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:1442)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:601)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
	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 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.MalformedParameterizedTypeException
	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:53)
	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
	at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
	at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
	at java.lang.reflect.Method.getGenericParameterTypes(Method.java:291)
	at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
	at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:114)
	at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
	at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
	at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1130)
	at java.beans.Introspector.getBeanInfo(Introspector.java:414)
	at java.beans.Introspector.getBeanInfo(Introspector.java:161)
	at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
	at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:149)
	at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:324)
	at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:354)
	at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:430)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1362)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
	... 27 more
Comment 2 Glyn Normington CLA 2013-03-04 07:00:20 EST
Not sure why this is happening. Note that Gemini Blueprint was based on Spring DM 2.0, so quite a few changes went in prior to GB 1.0.

I'm planning to ship GB 2.0 in the next couple of weeks, so if someone seeing this has the relevant time/skills, I would be happy to accept a patch. See the downloads page for 2.0 RC1. (Please note that I'm acting as caretaker project lead - I don't have any particularly deep skills in the project.)
Comment 3 Matt Bishop CLA 2013-03-04 23:59:33 EST
I looked at the example blueprint bundle but I cannot tell what version of Spring you are using.
Comment 4 Matt Magoffin CLA 2013-03-05 01:48:00 EST
I am using Spring 3.1.3.RELEASE.
Comment 5 Glyn Normington CLA 2013-03-19 11:54:51 EDT
I haven't gotten around to releasing, so I pushed out the target date to June. What's the outlook for a patch to this bug by then?
Comment 6 Matt Bishop CLA 2013-03-21 19:43:00 EDT
I have looked into this a bit today and I am not sure this is something we should fix because it uses the OSGi R5 API, while Gemini only supports 4.2.

In R5, ServiceReference has been changed to specify a type (ServiceReference<T>) whereas R4.2 does not.

I suspect support for R5 needs to be considered as a major epic, not a bug fix.
Comment 7 Glyn Normington CLA 2013-03-22 06:57:41 EDT
Thanks Matt. Let's flag the bug as an enhancement therefore and leave it in the backlog. I am not aware of much demand for stepping up to R5.
Comment 8 Olaf Otto CLA 2016-04-28 08:03:49 EDT
This is fixed via 489623 (Upgrade to R 5 compliance)

*** This bug has been marked as a duplicate of bug 489623 ***
Comment 9 Olaf Otto CLA 2017-05-09 09:41:41 EDT
Released - closing.