felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre De Rop (JIRA)" <j...@apache.org>
Subject [jira] [Work started] (FELIX-4832) ClassCastException with autoconfig Iterable fields
Date Thu, 19 Mar 2015 06:37:38 GMT

     [ https://issues.apache.org/jira/browse/FELIX-4832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Work on FELIX-4832 started by Pierre De Rop.
--------------------------------------------
> ClassCastException with autoconfig Iterable fields
> --------------------------------------------------
>
>                 Key: FELIX-4832
>                 URL: https://issues.apache.org/jira/browse/FELIX-4832
>             Project: Felix
>          Issue Type: Bug
>          Components: Dependency Manager
>    Affects Versions: org.apache.felix.dependencymanager-r1
>            Reporter: Pierre De Rop
>            Assignee: Pierre De Rop
>            Priority: Critical
>             Fix For: org.apache.felix.dependencymanager-r2
>
>
> When you configure a service dependency using auto configuration without specifying a
field name and when there is a field in the component instance with a type that is assignable
to an Iterable, but without a valid generic type, then a fatal class cast exception occurs.
> For example, assuming we have the following Activator code:
> {code}
> dm.createComponent()
> .setImplementation(Consumer.class)
> .add(dm.createServiceDependency().setService(OtherService.class).setRequired(true));
> {code}
> and the following consumer, which has a valid "m_providers" field, but another "m_notInjectMe"
field that must not be injected:
> {code}
> class Consumer {
>         // Auto injected
>         final Iterable<OtherService> m_providers = new ConcurrentLinkedQueue<>();
>       
>        // should never be injected, but causes a class cast exception:
>         final List m_notInjectMe = new ArrayList();
> ...
> }
> {code}
> Then the following exception occurs:
> {code}
> java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
>         at org.apache.felix.dm.impl.FieldUtil.mayInjectToIterable(FieldUtil.java:292)
>         at org.apache.felix.dm.impl.FieldUtil.mapField(FieldUtil.java:255)
>         at org.apache.felix.dm.impl.FieldUtil.injectDependencyField(FieldUtil.java:105)
>         at org.apache.felix.dm.impl.ComponentImpl.configureImplementation(ComponentImpl.java:1027)
>         at org.apache.felix.dm.impl.ComponentImpl.invokeAutoConfigDependencies(ComponentImpl.java:822)
>         at org.apache.felix.dm.impl.ComponentImpl.performTransition(ComponentImpl.java:543)
>         at org.apache.felix.dm.impl.ComponentImpl.handleChange(ComponentImpl.java:494)
>         at org.apache.felix.dm.impl.ComponentImpl.handleAdded(ComponentImpl.java:360)
>         at org.apache.felix.dm.impl.ComponentImpl.access$700(ComponentImpl.java:68)
>         at org.apache.felix.dm.impl.ComponentImpl$5.run(ComponentImpl.java:289)
>         at org.apache.felix.dm.impl.SerialExecutor.runTask(SerialExecutor.java:138)
>         at org.apache.felix.dm.impl.SerialExecutor.runTasks(SerialExecutor.java:120)
>         at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:86)
>         at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:105)
>         at org.apache.felix.dm.impl.ComponentImpl.handleEvent(ComponentImpl.java:284)
>         at org.apache.felix.dm.impl.ServiceDependencyImpl.addedService(ServiceDependencyImpl.java:256)
>         at org.apache.felix.dm.tracker.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1278)
>         at org.apache.felix.dm.tracker.ServiceTracker$Tracked$2.execute(ServiceTracker.java:1394)
>         at org.apache.felix.dm.tracker.ServiceTracker$Tracked$1.run(ServiceTracker.java:1191)
>         at org.apache.felix.dm.impl.SerialExecutor.runTask(SerialExecutor.java:138)
>         at org.apache.felix.dm.impl.SerialExecutor.runTasks(SerialExecutor.java:120)
>         at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:86)
>         at org.apache.felix.dm.tracker.ServiceTracker$Tracked.serviceChangedHideAspects(ServiceTracker.java:1197)
>         at org.apache.felix.dm.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1052)
>         at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:987)
>         at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)
>         at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)
>         at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4547)
>         at org.apache.felix.framework.Felix.registerService(Felix.java:3521)
>         at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)
>         at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:322)
>         at com.alcatel.as.service.metering2.SimpleMonitorable$1.run(SimpleMonitorable.java:164)
>         at com.alcatel.as.service.concurrent.SerialExecutor.runTasks(SerialExecutor.java:64)
>         at com.alcatel.as.service.concurrent.SerialExecutor.execute(SerialExecutor.java:49)
>         at com.alcatel.as.service.metering2.SimpleMonitorable.start(SimpleMonitorable.java:159)
>         at com.alcatel.as.service.metering2.impl.MonitorableSystem.start(MonitorableSystem.java:166)
>         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:606)
>         at org.apache.felix.dm.impl.InvocationUtil.invokeMethod(InvocationUtil.java:112)
>         at org.apache.felix.dm.impl.InvocationUtil.invokeCallbackMethod(InvocationUtil.java:67)
>         at org.apache.felix.dm.impl.ComponentImpl.invokeCallbackMethod(ComponentImpl.java:923)
>         at org.apache.felix.dm.impl.ComponentImpl.invoke(ComponentImpl.java:893)
>         at org.apache.felix.dm.impl.ComponentImpl.performTransition(ComponentImpl.java:555)
>         at org.apache.felix.dm.impl.ComponentImpl.handleChange(ComponentImpl.java:494)
>         at org.apache.felix.dm.impl.ComponentImpl.startDependencies(ComponentImpl.java:662)
>         at org.apache.felix.dm.impl.ComponentImpl.performTransition(ComponentImpl.java:537)
>         at org.apache.felix.dm.impl.ComponentImpl.handleChange(ComponentImpl.java:494)
>         at org.apache.felix.dm.impl.ComponentImpl.access$500(ComponentImpl.java:68)
>         at org.apache.felix.dm.impl.ComponentImpl$3.run(ComponentImpl.java:227)
>         at org.apache.felix.dm.impl.SerialExecutor.runTask(SerialExecutor.java:138)
>         at org.apache.felix.dm.impl.SerialExecutor.runTasks(SerialExecutor.java:120)
>         at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:86)
>         at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:105)
>         at org.apache.felix.dm.impl.ComponentImpl.start(ComponentImpl.java:223)
>         at org.apache.felix.dm.impl.ComponentScheduler.add(ComponentScheduler.java:71)
>         at org.apache.felix.dm.DependencyManager.add(DependencyManager.java:173)
>         at com.alcatel.as.service.metering2.impl.Activator.init(Activator.java:56)
>         at org.apache.felix.dm.DependencyActivatorBase.start(DependencyActivatorBase.java:75)
>         at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
>         at org.apache.felix.framework.Felix.activateBundle(Felix.java:2223)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:2141)
>         at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:977)
>         at com.alcatel.as.service.bundleinstaller.impl.BundleInstallerImpl$DeployedBundle.start(BundleInstallerImpl.java:961)
>         at com.alcatel.as.service.bundleinstaller.impl.BundleInstallerImpl.startBundles(BundleInstallerImpl.java:633)
>         at com.alcatel.as.service.bundleinstaller.impl.BundleInstallerImpl.frameworkEvent(BundleInstallerImpl.java:152)
>         at com.alcatel.as.service.bundleinstaller.impl.BundleInstallerImpl.start(BundleInstallerImpl.java:121)
>         at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
>         at org.apache.felix.framework.Felix.activateBundle(Felix.java:2223)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:2141)
>         at org.apache.felix.framework.Felix.updateBundle(Felix.java:2481)
>         at org.apache.felix.framework.BundleImpl.update(BundleImpl.java:995)
>         at org.apache.felix.framework.BundleImpl.update(BundleImpl.java:982)
>         at com.alcatel.as.service.bundleinstaller.impl.BundleInstallerImpl.checkSelfUpdate(BundleInstallerImpl.java:202)
>         at com.alcatel.as.service.bundleinstaller.impl.BundleInstallerImpl.frameworkEvent(BundleInstallerImpl.java:139)
>         at org.apache.felix.framework.util.EventDispatcher.invokeFrameworkListenerCallback(EventDispatcher.java:880)
>         at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:830)
>         at org.apache.felix.framework.util.EventDispatcher.run(EventDispatcher.java:1143)
>         at org.apache.felix.framework.util.EventDispatcher.access$000(EventDispatcher.java:55)
>         at org.apache.felix.framework.util.EventDispatcher$1.run(EventDispatcher.java:102)
>         at java.lang.Thread.run(Thread.java:745)
> {code}
> This exception prevents the correct component activation.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message