4 Replies Latest reply on Feb 9, 2002 5:59 PM by saylor09

    jboss3 ejb-local-ref from servlet

    miguel2

      Experts,

      could anybody please give a short comment about if and if yes how it is possible to invoke EJBs from servlets via their local interfaces in jboss3/jetty.

      I think there is a lot of speculation on this issue out there.

      thanx,

      Mige

        • 1. Re: jboss3 ejb-local-ref from servlet
          wklauser

          As far as my testing goes, this has always been possible with JBoss 3.0. The binding is a bit unexpected though, which might have stopped a few people from getting it working (including myself till 10 min. ago ;-)

          All local homes seem to be bound as "local/<ejb-name>". So, if you have got a bean named CurrencyBean with a local home CurrencyHome, you would look it up like this:

          InitialContext ic = new InitialContext();
          CurrencyHome c = (CurrencyHome) ic.lookup("local/CurrencyBean");

          Please note that there is no "java:" or "java:comp/env" or so involved here.

          Kind regards, Wilfried

          • 2. Re: jboss3 ejb-local-ref from servlet
            saylor09

            You may also want to note that you can redefine the local interface JNDI name in jboss.xml with <local-jndi-name>. For example:


              <enterprise-beans>
                
                  <ejb-name>Product</ejb-name>
                  <local-jndi-name>product/ejb/local/Product</local-jndi-name>
                
              </enterprise-beans>



            so instead of....

            (ProductLocalHome)context.lookup("local/Product");


            you can do....

            (ProductLocalHome)context.lookup("product/ejb/local/Product");


            This was not in the dtd. I'm not sure if it' still not there, but you should be able to use it.

            • 3. Re: jboss3 ejb-local-ref from servlet
              miguel2

              Two great answers !!

              However, the following questions seem to be left open:

              Using local-jndi-name do I need ejb-local-ref in my servlet ?

              Should lookup via "local/Beanname" work without any reference in my servlet ?

              (using jboss3/jetty from cvs)

              Mige


              • 4. Re: jboss3 ejb-local-ref from servlet
                saylor09

                local-jndi-name will redefine the global jndi name. You can either use the global name or use a reference defined with ejb-local-ref. However, the last I know of, Jetty does not support <ejb-local-ref>. But this may have changed recently.