2 Replies Latest reply on Jan 31, 2007 4:19 PM by toni

    Invoke a SLSB from a MBean

    toni

      Hi,

      how do I obtain a reference to a stateless session bean from within a MBean?

      Toni

        • 1. Re: Invoke a SLSB from a MBean
          peterj

          The same as from any other client, via JNDI.

          • 2. Re: Invoke a SLSB from a MBean
            toni

            Well, that's pretty obvious but I was wondering about the naming convention. Here is the code and naming convention:

            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            p.put(Context.PROVIDER_URL, "localhost:1099");
            context = new InitialContext(p);

            Object object = context.lookup("/applicationNameOfEarWithoutExtension/NameOfSessionBeanInNameAnnotation/local");

            So if you work with Seam and deploy a ear called "myapp.ear" and tag a bean with @Name("testSessionBean"), the you need to call:

            Object object = context.lookup("/myapp/testSessionBean/local");