[
https://issues.apache.org/jira/browse/KARAF-6537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jean-Baptiste Onofré updated KARAF-6537:
----------------------------------------
Fix Version/s: (was: 4.3.0)
4.3.1
> Runtime error when trying to use generics in blueprint
> ------------------------------------------------------
>
> Key: KARAF-6537
> URL: https://issues.apache.org/jira/browse/KARAF-6537
> Project: Karaf
> Issue Type: Bug
> Components: karaf
> Affects Versions: 4.2.6
> Environment: Karaf 4.2.6
> Java JDK 11.0.5
> Reporter: Jerome MICHEL
> Assignee: Jean-Baptiste Onofré
> Priority: Major
> Fix For: 4.2.11, 4.3.1
>
>
> We currently have a working project on Karaf 4.1.1 & Java-8 but we want to
> migrate to Java-11 so we needed to migrate to Karaf 4.2.x which has Java-11
> support.
> We choose to migrate to Karaf 4.2.6 due to issues with Log4j and pax-logging
> dependency in Karaf 4.2.7
> While we were able to create generic beans from blueprint in Karaf 4.1.1, it
> seems the mecanism has changed and this is no longuer the case, every
> constructor we use with Generics now throws a RuntimeException. As an example
> we used a lot of SimpleObjectProperty which was included in JavaFX in Java-8
> (We also integrate OpenJFX through our migration to Java-11). We had this
> declaration which was working really fine in Karaf 4.1.1 :
> {code:java}
> <bean id="MySuperProperty" class="javafx.beans.property.SimpleObjectProperty">
> <argument ref="MySuperObject" />
> </bean>{code}
> Now with Karaf 4.2.6 the bundle containing this declaration fail to start and
> a diag for this bundles gives :
> {code:java}
> Status: Failure Blueprint Exception: Unable to instantiate components
> org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
> instantiate components at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:741)
> at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:433)
> at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:298)
> at
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at
> org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
> at
> org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:45)
> at
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at
> java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
> at
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> at
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> at java.base/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.base/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}
>
> Trying with other class we came to a conclusion that the faulty stuff was the
> Generic from the constructor of the SimpleObjectProperty which may be :
> {code:java}
> public class SimpleObjectProperty<T> extends ObjectPropertyBase<T> {
> [...]
> public SimpleObjectProperty(T var) {...}
> [...]
> }{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)