1

I have CDI RequestScoped bean and much more java class that are not beans. in any of these java classes, I want to use my bean but it can be injected (why? I do not know) one possible way is using this code :

final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
EntityManagment em = (EntityManagment) context.lookup("java:app/drools-guvnor/EntityManagment");

that work well if my bean is stateless and localbean. what I can do for none stateless and localbeans?

moosy
  • 55
  • 8
  • You say that your beans cannot be injected or I'm understanding you wrong? – Adrian Mitev May 20 '14 at 13:01
  • Please provide more code examples from your app, it is really hard to understand what your problem is. What platform are you working on? Tomcat+CDI? JBoss? – Jan Galinski May 20 '14 at 14:34
  • Ok, I am running jbpm suite on jboss and try to lookup requestscope bean that until I can't (Jan) and adrian you got it right bean injection no work on **none bean classes**, at least for me – moosy May 21 '14 at 05:00

1 Answers1

1

There is no JNDI-Name for CDI given.

You could either register them yourself or you create an EJB that has been injected with your object. Then you can lookup this EJB and get your injected object from there.

Lukas Eichler
  • 5,689
  • 1
  • 24
  • 43