- 
        1. Re: BeanManager not accessible via JNDIlightguard Mar 26, 2012 2:38 PM (in response to marx3)That should work, sounds like a bug in AS7 
- 
        2. Re: BeanManager not accessible via JNDImarx3 Mar 27, 2012 2:51 AM (in response to lightguard)I've partially found a problem - BeanManager in JNDI is available only for EE components. I'm trying to use DI in Quartz job. If I get stateless component from JNDI, and it use @EJB for injection - everything works. But if stateless uses @Inject - all injected fields are null. So I'm trying to use BeanManager for getting components (hopefully it will manage @Inject for me) , but I can't find BeanManager in JNDI. I even tried to get BeanManager from stateles, it works, but if I try to use it - it fails with exception: "java.lang.IllegalStateException: JBAS011048: Failed to construct component instance". So I think that using injection in Quartz job isn't really possible, and I have to rewrite all @Inject=>@EJB 
- 
        3. Re: BeanManager not accessible via JNDIlightguard Mar 27, 2012 3:58 PM (in response to marx3)Currently you'd need to save off the BeanManager in an extension and get it that way. According to Pete, this situation will be fixed in CDI 1.1 
- 
        4. Re: BeanManager not accessible via JNDIradzish Mar 29, 2012 12:33 PM (in response to lightguard)Could you please provide more information on how can I do that? 
- 
        5. Re: BeanManager not accessible via JNDIlightguard Mar 29, 2012 1:01 PM (in response to radzish)There's obviously more there than you probably need, but you should be able to get the idea. 
- 
        6. Re: BeanManager not accessible via JNDImark_1 Sep 6, 2012 5:39 AM (in response to marx3)Hi, I faced the same problem, but I resolved it in a different way. I defined a class extending the org.quartz.simpl.PropertySettingJobFactory, which is responsible to create the quartz job, and I injected in it the beanManager. Then I've overridden the newJob method, in order to control the instantiation of the jobs, making use of the beanManager. This is a code snippet of my class: @Inject private BeanManager beanManager; @Override public Job newJob(TriggerFiredBundle bundle, Scheduler Scheduler) throws SchedulerException { Job job = super.newJob(bundle, Scheduler); Class<? extends Job> clazz=job.getClass(); System.out.println("CDI FACTORY___"); if (beanManager != null) { System.out.println("BEANMANAGER"); CreationalContext<Job> ctx = beanManager .createCreationalContext(null); @SuppressWarnings("unchecked") AnnotatedType<Job> type =(AnnotatedType<Job>) beanManager .createAnnotatedType(clazz); InjectionTarget<Job> it = beanManager .createInjectionTarget(type); it.inject(job, ctx); } return job; } I hope it is useful bye 
- 
        7. Re: BeanManager not accessible via JNDIcpineda Oct 4, 2012 3:22 PM (in response to marx3)I found and implemented this code in my POJO: public BeanManager getBeanManager() { try{ InitialContext initialContext = new InitialContext(); return (BeanManager) initialContext.lookup("java:comp/BeanManager"); }catch (NamingException e) { log.error("Couldn't get BeanManager through JNDI"); return null; } } @SuppressWarnings("unchecked") public UsuarioBean getFacade() { BeanManager bm = getBeanManager(); if (bm!=null) { Bean<UsuarioBean> bean = (Bean<UsuarioBean>) bm.getBeans(UsuarioBean.class).iterator().next(); CreationalContext<UsuarioBean> ctx = bm.createCreationalContext(bean); UsuarioBean dao = (UsuarioBean) bm.getReference(bean, UsuarioBean.class, ctx); // this could be inlined, but intentionally left this way return dao; } return null; } BeanManager also be possible with Idetity Seam 3? For example: getIdentity public Identity () { try { InitialContext initialContext = new InitialContext (); return (Identity) initialContext.lookup ("java: comp / Identity"); } catch (NamingException e) { log.error ("Could not get BeanManager through JNDI"); return null; } } 
- 
        8. Re: BeanManager not accessible via JNDIlightguard Oct 4, 2012 4:07 PM (in response to cpineda)I highly doubt it. You could get it from the BeanManager though. 
- 
        9. Re: BeanManager not accessible via JNDIcpineda Oct 4, 2012 4:43 PM (in response to lightguard)BeanManager get the embargo? as serious? 
- 
        10. Re: BeanManager not accessible via JNDIlightguard Oct 4, 2012 4:52 PM (in response to cpineda)I don't believe PicketLink puts anything in JNDI, I know Seam 3 doesn't put anything in JNDI. It's CDI that has specified that the BeanManager is placed in JNDI. Identity is from PicketLink. 
- 
        11. Re: BeanManager not accessible via JNDIcpineda Oct 4, 2012 5:08 PM (in response to lightguard)Ok, but can not find any solution q let me somehow manipulate the Identity, not @ Injetc if not through programming, as I stated above. 
- 
        12. Re: BeanManager not accessible via JNDIlightguard Oct 4, 2012 5:28 PM (in response to cpineda)If you can get the BeanManager, you can look up the Identity instance manually. As far as I can see, that's the only way you're going to be able to access it and have it work correctly. 
- 
        13. Re: BeanManager not accessible via JNDIcpineda Oct 4, 2012 5:48 PM (in response to lightguard)Exactly, but not how to get the BeanManager, try the JNDI but casting problems 
- 
        14. Re: BeanManager not accessible via JNDIlightguard Oct 4, 2012 6:04 PM (in response to cpineda)Going back up the thread are you in an EJB or just a POJO? If it's a POJO, you're out of luck unless you do what we've done in Apache DeltaSpike and store the BeanManager in a class using an extension. 
 
     
     
     
    