Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-339

Injecting Non-Contextual Beans Causes NPE in WebBeansUtil

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: M4, 1.0.0-alpha-1
    • Fix Version/s: 1.0.0-alpha-1
    • Component/s: Injection and Lookup
    • Labels:
      None

      Description

      I've got an inject method for injecting non-contextual objects:

      @SuppressWarnings("unchecked")
      public <T> void inject(T instance)

      { BeanManager mgr = BeanManagerImpl.getManager(); AnnotatedType<T> annotatedType = mgr.createAnnotatedType((Class<T>) instance.getClass()); InjectionTarget<T> injectionTarget = mgr.createInjectionTarget(annotatedType); CreationalContext<T> context = mgr.createCreationalContext(null); injectionTarget.inject(instance, context); }

      But, when I try it, I get a NPE in WebBeansUtil:

      java.lang.NullPointerException
      at org.apache.webbeans.util.WebBeansUtil.getObjectFromCreationalContext(WebBeansUtil.java:2643)
      at org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:733)
      at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:118)
      at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:54)
      at org.apache.webbeans.component.AbstractInjectionTargetBean.injectField(AbstractInjectionTargetBean.java:354)
      at org.apache.webbeans.component.AbstractInjectionTargetBean.injectFields(AbstractInjectionTargetBean.java:314)
      at org.apache.webbeans.portable.creation.InjectionTargetProducer.inject(InjectionTargetProducer.java:58)

        Attachments

        1. OWB-339.patch
          7 kB
          James Carman

          Activity

            People

            • Assignee:
              struberg Mark Struberg
              Reporter:
              jwcarman James Carman
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: