[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Resolved] (ARIES-1046) blueprintContainer.getComponentInstance causes NPE for inline beans


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

Martin Lichtin resolved ARIES-1046.
-----------------------------------
    Resolution: Cannot Reproduce

> blueprintContainer.getComponentInstance causes NPE for inline beans
> -------------------------------------------------------------------
>
>                 Key: ARIES-1046
>                 URL: https://issues.apache.org/jira/browse/ARIES-1046
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>            Reporter: Martin Lichtin
>            Priority: Major
>
> Using the following code (more or less) as part of the init() method of a bean
>       Collection<BeanMetadata> allBeans = blueprintContainer.getMetadata(BeanMetadata.class);
>       for (BeanMetadata beanData : allBeans) {
>         Object o = blueprintContainer.getComponentInstance(beanData.getId());
>       }
> I receive a NPE:
> org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean ...
>     at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[7:org.apache.aries.blueprint.core:1.1.0]
>     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_13]
>     at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_13]
>     at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)[7:org.apache.aries.blueprint.core:1.1.0]
>     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_13]
>     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_13]
>     at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_13]
>     at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[7:org.apache.aries.blueprint.core:1.1.0]
>     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_13]
>     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_13]
>     at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_13]
>     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_13]
>     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_13]
>     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_13]
>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_13]
>     at java.lang.Thread.run(Thread.java:722)[:1.7.0_13]
> Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: Cound not create component instance for null
>     at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:752)[7:org.apache.aries.blueprint.core:1.1.0]
>     at ...
>     at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_13]
>     at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_13]
>     at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[7:org.apache.aries.blueprint.core:1.1.0]
>     ... 24 more
> Caused by: java.lang.NullPointerException
>     at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:332)[:1.7.0_13]
>     at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:987)[:1.7.0_13]
>     at org.apache.aries.blueprint.container.BlueprintRepository.getInstance(BlueprintRepository.java:93)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:228)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[7:org.apache.aries.blueprint.core:1.1.0]
>     at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:746)[7:org.apache.aries.blueprint.core:1.1.0]
>     ... 31 more
> This happens for beans declared inline:
>     <bean id="a"
>         class="A">
>         <property name="p">
>             <bean class="B" />
>         </property>
>     </bean>
> It looks as if there is no "id" (auto-)assigned to bean instance of class B.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)