You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Martin Lichtin (JIRA)" <ji...@apache.org> on 2013/04/04 16:15:20 UTC

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

Martin Lichtin created ARIES-1046:
-------------------------------------

             Summary: 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


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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira