Hi David, I already know this method but I need to inject (lookup) ejbs dynamically so it is useless for me...
I guess my only choice left is to use the 'new InitialContext()' alternative? Thanks Christian On Sun, May 3, 2009 at 3:42 PM, David Blevins <[email protected]> wrote: > Hi Christian, > > Try this: > > �...@stateless > public class OrangeBean implements OrangeLocal > { > > public String echo(String s) > { > return s; > } > } > > �...@ejb(name="orange", beanInterface = OrangeLocal.class) > �...@stateless > public class TestBean implements TestLocal > { > @Resource > private SessionContext sessionContext; > > public void test() > { > OrangeLocal orangeLocal = (OrangeLocal) > sessionContext.lookup("orange"); > } > } > > The @EJB annotation declares a reference to the Orange bean. The > sessionContext.lookup is a convenience method around 'new > InitialContext().lookup("java:comp/env/"+name)' and by default the > 'java:comp/env' namespace is empty unless references are declared via > annotation or xml. > > -David > > > On May 1, 2009, at 2:28 PM, Christian Bourque wrote: > >> Hi, >> >> What JNDI path should I use to lookup an EJB using a SessionContext >> which has been injected: >> >> @Stateless >> public class TestBean implements TestLocal >> { >> @Resource >> private SessionContext sessionContext; >> >> public void test() >> { >> sessionContext.lookup("???"); >> } >> } >> >> I've tried different combinations without any success... >> >> Thanks >> >> Christian >> > >
