Hi Mike, that's an easy one :) You tried to access a @javax.inject.Singleton scoped bean in a Thread where this context didn't get activated.
I generally recommend against using the atinject @Singleton! Contrary to the javax.ejb.Singleton it has an undefined lifecycle, so it's barely useful. Please use a simple @ApplicationScoped instead. LieGrue, strub PS: if you start new Threads manually yourself, then please look at DeltaSpike-CdiCtrl ContextControl. ----- Original Message ----- > From: Mike Olson <[email protected]> > To: [email protected] > Cc: > Sent: Thursday, January 17, 2013 9:52 AM > Subject: WebBeans context with scope type annotation @Singleton does not > exist within current thread > > Hello, > > > I am trying to figure out exactly what this exception is trying to tell me. > I > have multiple web applications that are communicating with JMS and this is > occurring during a MessageListener call back so my assumption is that it has > something to do with being multi-threaded. However, I am also using the > "Provider" again so it could be another issue with that. > > I am doing something similar to: > > @Inject > Provider<Foo> fooProvider; > > public void onMessage(Message m) { > fooProvider.get(); > } > > > In the ".get()" call is where the exception occurs. I have been > through the code and inspected all of the Inject fields in the class > hierarchy > of "Foo". There are some that are scoped as @Singleton. I have > removed that scope from all of them, but I still get the same exception. > > > Anyone have any ideas? Here is the traceback. > Thanks > Mike > > > javax.enterprise.context.ContextNotActiveException: WebBeans context with > scope > type annotation @Singleton does not exist within current thread > at > org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:351) > at > org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:861) > at > org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:759) > at > org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:136) > at > org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:59) > at > org.apache.webbeans.component.AbstractInjectionTargetBean.injectField(AbstractInjectionTargetBean.java:387) > at > org.apache.webbeans.component.AbstractInjectionTargetBean.injectFields(AbstractInjectionTargetBean.java:324) > at > org.apache.webbeans.portable.creation.InjectionTargetProducer.inject(InjectionTargetProducer.java:95) > at > org.apache.webbeans.component.InjectionTargetWrapper.inject(InjectionTargetWrapper.java:76) > at > org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:181) > at > org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:70) > at > org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:132) > at > org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:872) > at > org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:753) > at > org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:136) > at > org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:59) > at > org.apache.webbeans.component.AbstractInjectionTargetBean.injectField(AbstractInjectionTargetBean.java:387) > at > org.apache.webbeans.component.AbstractInjectionTargetBean.injectSuperFields(AbstractInjectionTargetBean.java:368) > at > org.apache.webbeans.portable.creation.InjectionTargetProducer.inject(InjectionTargetProducer.java:93) > at > org.apache.webbeans.component.InjectionTargetWrapper.inject(InjectionTargetWrapper.java:76) > at > org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:181) > at > org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:70) > at > org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:132) > at > org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:872) > at > org.apache.webbeans.inject.instance.InstanceImpl.get(InstanceImpl.java:126) > > -- Mike Olson >
