[ https://issues.apache.org/jira/browse/ARIES-1957?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jerome MICHEL updated ARIES-1957: --------------------------------- Description: We are currently trying to migrate from Karaf 4.1.1 which uses Apache Aries Blueprint v1.8.0 to Karaf 4.2.6 which uses Aries Blueprint v1.10.2 While we were able to handle beans with Generic constructors in the previous version, any usage of Generics now throws a RuntimeException saying the type is not known. With this definition in Blueprint : {code:java} <bean id="sharedModel" class="javafx.beans.property.SimpleObjectProperty> <argument> <bean class="com.example.MySuperModel" /> </argument> </bean>{code} The definition of the javaFX class is like : {code:java} public class SimpleObjectProperty<T> extends ObjectPropertyBase<T> { [...] public SimpleObjectProperty() { ... } public SimpleObjectProperty(T var) { ... } }{code} The instanciation of this bean result in : {code:java} 2019-12-05T09:35:44,162 | ERROR | Blueprint Extender: 3 | org.apache.aries.blueprint.container.BlueprintContainerImpl | 102 - org.apache.aries.blueprint.core - 1.10.2 | Unable to start container for blueprint bundle com.test.hmi/1.4.0.SNAPSHOT org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to instantiate components at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:741) ~[102:org.apache.aries.blueprint.core:1.10.2] at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:433) [102:org.apache.aries.blueprint.core:1.10.2] at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:298) [102:org.apache.aries.blueprint.core:1.10.2] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106) [102:org.apache.aries.blueprint.core:1.10.2] at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:45) [102:org.apache.aries.blueprint.core:1.10.2] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:834) [?:?] Caused by: java.lang.RuntimeException: Unknown type T at org.apache.aries.blueprint.utils.generics.TypeInference.getParameters(TypeInference.java:449) ~[?:?] at org.apache.aries.blueprint.utils.generics.TypeInference.match(TypeInference.java:262) ~[?:?] at org.apache.aries.blueprint.utils.generics.TypeInference.findMatching(TypeInference.java:231) ~[?:?] at org.apache.aries.blueprint.utils.generics.TypeInference.findMatchingConstructors(TypeInference.java:125) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.findMatchingConstructors(BeanRecipe.java:373) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.getInstanceFromType(BeanRecipe.java:346) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:283) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:685) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666) ~[?:?] at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81) ~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?] at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90) ~[?:?] at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:360) ~[?:?] at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:190) ~[?:?] at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:737) ~[?:?] ... 12 more {code} We tried to investigate around this error trying to know if we made a mistake on our side. As far as we tested and tried to debug in the blueprint's classes, we found that when blueprint is matching constructors from what the class has and the parameters he received only _Class_ and _ParametrizedType_ are handled in _TypeInference#getParameters(Type)_. But due to genericity, we arrived with a _TypeVariable,_ which is of type T with Object as generic bound. So maybe this type can also be handled like other cases ? was: We are currently trying to migrate from Karaf 4.1.1 which uses Apache Aries Blueprint v1.8.0 to Karaf 4.2.6 which uses Aries Blueprint v1.10.2 While we were able to handle beans with Generic constructors in the previous version, any usage of Generics now throws a RuntimeException saying the type is not known. With this definition in Blueprint : {code:java} <bean id="sharedModel" class="javafx.beans.property.SimpleObjectProperty> <argument> <bean class="com.example.MySuperModel" /> </argument> </bean>{code} The definition of the javaFX class is like : {code:java} public class SimpleObjectProperty<T> extends ObjectPropertyBase<T> { [...] public SimpleObjectProperty() { ... } public SimpleObjectProperty(T var) { ... } }{code} The instanciation of this bean result in : {code:java} 2019-12-05T09:35:44,162 | ERROR | Blueprint Extender: 3 | org.apache.aries.blueprint.container.BlueprintContainerImpl | 102 - org.apache.aries.blueprint.core - 1.10.2 | Unable to start container for blueprint bundle com.tus.hci.project.flf.hmi/1.4.0.SNAPSHOT org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to instantiate components at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:741) ~[102:org.apache.aries.blueprint.core:1.10.2] at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:433) [102:org.apache.aries.blueprint.core:1.10.2] at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:298) [102:org.apache.aries.blueprint.core:1.10.2] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106) [102:org.apache.aries.blueprint.core:1.10.2] at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:45) [102:org.apache.aries.blueprint.core:1.10.2] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:834) [?:?] Caused by: java.lang.RuntimeException: Unknown type T at org.apache.aries.blueprint.utils.generics.TypeInference.getParameters(TypeInference.java:449) ~[?:?] at org.apache.aries.blueprint.utils.generics.TypeInference.match(TypeInference.java:262) ~[?:?] at org.apache.aries.blueprint.utils.generics.TypeInference.findMatching(TypeInference.java:231) ~[?:?] at org.apache.aries.blueprint.utils.generics.TypeInference.findMatchingConstructors(TypeInference.java:125) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.findMatchingConstructors(BeanRecipe.java:373) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.getInstanceFromType(BeanRecipe.java:346) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:283) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:685) ~[?:?] at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666) ~[?:?] at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81) ~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?] at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90) ~[?:?] at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:360) ~[?:?] at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:190) ~[?:?] at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:737) ~[?:?] ... 12 more {code} We tried to investigate around this error trying to know if we made a mistake on our side. As far as we tested and tried to debug in the blueprint's classes, we found that when blueprint is matching constructors from what the class has and the parameters he received only _Class_ and _ParametrizedType_ are handled in _TypeInference#getParameters(Type)_. But due to genericity, we arrived with a _TypeVariable,_ which is of type T with Object as generic bound. So maybe this type can also be handled like other cases ? > Using Generic types throws Unknown type exception > ------------------------------------------------- > > Key: ARIES-1957 > URL: https://issues.apache.org/jira/browse/ARIES-1957 > Project: Aries > Issue Type: Bug > Components: Blueprint > Affects Versions: blueprint-core-1.8.0 > Environment: Karaf 4.2.6 > JDK 11.5 > Reporter: Jerome MICHEL > Assignee: Jean-Baptiste Onofré > Priority: Major > Fix For: blueprint-core-1.8.4, blueprint-core-1.9.1 > > > We are currently trying to migrate from Karaf 4.1.1 which uses Apache Aries > Blueprint v1.8.0 to Karaf 4.2.6 which uses Aries Blueprint v1.10.2 > While we were able to handle beans with Generic constructors in the previous > version, any usage of Generics now throws a RuntimeException saying the type > is not known. > With this definition in Blueprint : > {code:java} > <bean id="sharedModel" class="javafx.beans.property.SimpleObjectProperty> > <argument> > <bean class="com.example.MySuperModel" /> > </argument> > </bean>{code} > The definition of the javaFX class is like : > > > {code:java} > public class SimpleObjectProperty<T> extends ObjectPropertyBase<T> { > [...] > public SimpleObjectProperty() { > ... > } > public SimpleObjectProperty(T var) { > ... > } > }{code} > The instanciation of this bean result in : > > > {code:java} > 2019-12-05T09:35:44,162 | ERROR | Blueprint Extender: 3 | > org.apache.aries.blueprint.container.BlueprintContainerImpl | 102 - > org.apache.aries.blueprint.core - 1.10.2 | Unable to start container for > blueprint bundle com.test.hmi/1.4.0.SNAPSHOT > org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to > instantiate components > at > org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:741) > ~[102:org.apache.aries.blueprint.core:1.10.2] > at > org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:433) > [102:org.apache.aries.blueprint.core:1.10.2] > at > org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:298) > [102:org.apache.aries.blueprint.core:1.10.2] > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] > at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] > at > org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106) > [102:org.apache.aries.blueprint.core:1.10.2] > at > org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:45) > [102:org.apache.aries.blueprint.core:1.10.2] > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] > at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) > [?:?] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > [?:?] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > [?:?] > at java.lang.Thread.run(Thread.java:834) [?:?] > Caused by: java.lang.RuntimeException: Unknown type T > at > org.apache.aries.blueprint.utils.generics.TypeInference.getParameters(TypeInference.java:449) > ~[?:?] > at > org.apache.aries.blueprint.utils.generics.TypeInference.match(TypeInference.java:262) > ~[?:?] > at > org.apache.aries.blueprint.utils.generics.TypeInference.findMatching(TypeInference.java:231) > ~[?:?] > at > org.apache.aries.blueprint.utils.generics.TypeInference.findMatchingConstructors(TypeInference.java:125) > ~[?:?] > at > org.apache.aries.blueprint.container.BeanRecipe.findMatchingConstructors(BeanRecipe.java:373) > ~[?:?] > at > org.apache.aries.blueprint.container.BeanRecipe.getInstanceFromType(BeanRecipe.java:346) > ~[?:?] > at > org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:283) > ~[?:?] > at > org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:685) > ~[?:?] > at > org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666) > ~[?:?] > at > org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81) > ~[?:?] > at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?] > at > org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90) > ~[?:?] > at > org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:360) > ~[?:?] > at > org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:190) > ~[?:?] > at > org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:737) > ~[?:?] > ... 12 more > {code} > > We tried to investigate around this error trying to know if we made a mistake > on our side. > As far as we tested and tried to debug in the blueprint's classes, we found > that when blueprint is matching constructors from what the class has and the > parameters he received only _Class_ and _ParametrizedType_ are handled in > _TypeInference#getParameters(Type)_. But due to genericity, we arrived with a > _TypeVariable,_ which is of type T with Object as generic bound. > So maybe this type can also be handled like other cases ? -- This message was sent by Atlassian Jira (v8.3.4#803005)