Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » SpringBlueprintConverterService$BlueprintConverterException with generics
SpringBlueprintConverterService$BlueprintConverterException with generics [message #1014480] Mon, 25 February 2013 17:35 Go to next message
Matt Magoffin is currently offline Matt Magoffin
Messages: 2
Registered: July 2009
Junior Member
Hello, I'm having an exception while trying to wire up some services using generics with Gemini Blueprint. I've created a simple sample bundle that demonstrates my problem. The Blueprint XML:

<bean id="subDatumDataSource" class="test.SimpleSubDatumDataSource"/>

<bean id="proxyDatumDataSource" class="test.ProxyDatumDataSource">
	<argument ref="subDatumDataSource"/>
</bean>


where ProxyDatumDataSource is defined as

public class ProxyDatumDataSource<T extends Datum> implements DatumDataSource<T>


and SimpleSubDatumDataSource is defined as

public class SimpleSubDatumDataSource implements DatumDataSource<SubDatum>


and SubDatum is defined as

public interface SubDatum extends Datum


The resulting exception is:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'proxyDatumDataSource' defined in OSGi resource[bundleentry://85.fwk368471295/OSGI-INF/blueprint/module.xml|bnd.id=85|bnd.sym=reified-test]: Unsatisfied dependency expressed through constructor argument with index 0 of type [test.DatumDataSource]: Could not convert constructor argument value of type [test.SimpleSubDatumDataSource] to required type [test.DatumDataSource]: Failed to convert value of type 'test.SimpleSubDatumDataSource' to required type 'test.DatumDataSource'; nested exception is org.eclipse.gemini.blueprint.blueprint.container.SpringBlueprintConverterService$BlueprintConverterException: No conversion found for generic argument(s) for reified type interface test.Datum source type test.SimpleSubDatumDataSource| targetType =interface test.DatumDataSource
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:702)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
	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.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
	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$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)


It seems that since SimpleSubDatumDataSource implements DatumDataSource<SubDatum> instead of DatumDataSource<Datum> Gemini isn't able to perform the conversion? I tried using some different approaches, like a factory method, but I wasn't successful. Is this a bug, or can I work around this somehow?
Re: SpringBlueprintConverterService$BlueprintConverterException with generics [message #1014852 is a reply to message #1014480] Tue, 26 February 2013 10:36 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
I'm no expert on Java generics, but module.xml is trying to cause the creation of an instance of the type ProxyDatumDataSource<T extends Datum> in which the type parameter T is "flapping".
Re: SpringBlueprintConverterService$BlueprintConverterException with generics [message #1014915 is a reply to message #1014852] Tue, 26 February 2013 13:36 Go to previous messageGo to next message
Matt Magoffin is currently offline Matt Magoffin
Messages: 2
Registered: July 2009
Junior Member
So far the only way I've found to work around it is to use a factory method that accepts an Object, e.g.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static ProxyDatumDataSource<? extends Datum> getInstance(Object delegate) {
	ProxyDatumDataSource<? extends Datum> ds = new ProxyDatumDataSource<Datum>(
			(DatumDataSource) delegate);
	return ds;
}


Is this just something Blueprint/Spring can't deal with (in terms of the generics)?
Re: SpringBlueprintConverterService$BlueprintConverterException with generics [message #1015046 is a reply to message #1014915] Wed, 27 February 2013 04:39 Go to previous message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
Matt Magoffin wrote on Tue, 26 February 2013 18:36
Is this just something Blueprint/Spring can't deal with (in terms of the generics)?

Probably. Personally, I would steer clear of anything more than the most trivial use of generics with Blueprint.
Previous Topic:Any example for Gemini JPA Eclipse RCP ?
Next Topic:Multiple version of bundle OSGI / BluePrint
Goto Forum:
  


Current Time: Fri Aug 22 02:07:06 EDT 2014

Powered by FUDForum. Page generated in 0.01669 seconds