[jboss-user] [EJB 3.0] - Newbie EJB 3 JNDI question

DeanoUK do-not-reply at jboss.com
Tue Dec 11 14:59:54 EST 2007


Hi all.

Still confused as to how I should properly use EJB injection within another EJB.

Say I have an EJB called MyBean. Within it I define the JNDI mapping to be: @LocalBinding(jndiBinding="ejb/MyBean/local")

Within another EJB I grab it using:
@EJB(name = "ejb/MyBean", beanInterface = MyBeanLocal.class)

Now currently, I then look it up using

  | InitialContext ctx = new InitialContext();
  | MyBeanLocal myBeanLocal = (MyBeanLocal ) ctx.lookup("java:comp/env/ejb/MyBean");


In EJB3, what is the best way of actually injecting a bean into the local JNDI and referencing it, ensuring application server portability?
I'm still very unsure I'm not going way over the top by ensuring it's injected into the local JNDI from the ENC and then looked up in the local JNDI.

Any direction would be most helpful, thanks in advance.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112073#4112073

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112073



More information about the jboss-user mailing list