I'm using BeanManager to lookup CDI beans when I can't inject them e.g. when I need to programmatically inject those beans in spawned threads. But the problem is that BeanManager returns an instance of ApplicationScoped bean which is not really ApplicationScoped. Because when I inject that bean again in some EJB bean (this time by using @Inject annotation), it creates another instance of the same applicationScoped bean. It doesn't use the instance created by BeanManager.
Will appreciate any help. Below is the code I'm using to inject beans using BeanManager. Is there something wrong with this code?
T myInstance = null;
Set<Bean<?>> lookedBeansSet = beanManager.getBeans(type); //type is the interface class of ApplicationScoped bean