Thanks David!
On Mon, May 4, 2009 at 4:08 PM, David Blevins <[email protected]> wrote: > That will also work. Currently the EJBs are underneath "openejb:local/"+ > jndiName. So if the beans JNDI name is "OrangeLocal" it can be found under > "openejb:local/OrangeLocal". > > Note though that the LocalInitialContextFactory approach to looking up beans > is the recommended approach and guaranteed stable in future releases and > functionally equivalent to an "openejb:local/" lookup. > > We can't guarantee that the locations of things under "openejb:" won't > change and it should be considered a stop-gap solution till the portable > global JNDI functionality is rolled out in Java EE 6 (JSR-316). > > I was actually hoping we could skip the need for a proprietary global > namespace and go straight to the portable spec defined version, but the > discussion on that feature in the 316 group is still very much in progress. > > -David > > On May 4, 2009, at 12:29 PM, Christian Bourque wrote: > >> Ok... Would it be possible to do it using the new "openejb:" jndi url >> prefix? >> >> Thanks >> >> Christian >> >> On Mon, May 4, 2009 at 1:19 AM, David Blevins <[email protected]> >> wrote: >>> >>> Yes, that will give the namespace where you can lookup any ejb from any >>> app. >>> >>> -David >>> >>> On May 3, 2009, at 7:32 PM, Christian Bourque wrote: >>> >>>> Ok but isn't there a global JNDI namespace in OpenEJB? Like in most >>>> other Java EE implementations... >>>> >>>> On Sun, May 3, 2009 at 9:50 PM, David Blevins <[email protected]> >>>> wrote: >>>>> >>>>> On May 3, 2009, at 5:31 PM, Christian Bourque wrote: >>>>> >>>>>> 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? >>>>> >>>>> Doing 'new InitialContext()' is going to get you the same JNDI >>>>> namespace >>>>> that sessionContext.lookup() gives you, so that won't work for what you >>>>> need. >>>>> >>>>> You can use the LocalInitialContextFactory if you want to lookup any >>>>> bean >>>>> deployed in the container system. >>>>> >>>>> Properties properties = new Properties(); >>>>> properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, >>>>> "org.apache.openejb.client.LocalInitialContextFactory"); >>>>> >>>>> initialContext = new InitialContext(properties); >>>>> >>>>> That will bypass the bean's private jndi namespace and hook you up with >>>>> the >>>>> generic "client" namespace. >>>>> >>>>> -David >>>>> >>>>> >>>>>> >>>>>> >>>>>> 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 >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>> >>> >>> >> > >
