1 Reply Latest reply on Dec 1, 2004 1:21 AM by Joan Horta Tosas

    Setting the local-jndi-name of a local Session Bean

    pergesu Newbie

      I'm trying to write a very simple local session bean. I'm actually doing the exact same app as in the JBossIDE tutorial, with a session bean that computes Fibonacci numbers, and a servlet client. The difference is that my session bean is local, whereas the tutorial one is a remote EJB.

      I can get my client to work...just not how I want. I specify a local-jndi-name in the deployment descriptors, but regardless, JBoss still gives it the same name. Here are the relevant portions of the deployment descriptors:

      jboss.xml

      <session>
       <ejb-name>Fibo</ejb-name>
       <local-jndi-name>ejb/fibo/Fibo</local-jndi-name>
      
       <method-attributes>
       </method-attributes>
      </session>
      


      web.xml
      <ejb-local-ref>
       <description><![CDATA[Reference to the Fibo EJB]]></description>
       <ejb-ref-name>ejb/Fibo</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <local-home>tutorial.interfaces.FiboLocalHome</local-home>
       <local>tutorial.interfaces.FiboLocal</local>
      </ejb-local-ref>
      


      jboss-web.xml
      <ejb-local-ref>
       <ejb-ref-name>ejb/Fibo</ejb-ref-name>
       <local-jndi-name>ejb/fibo/Fibo</local-jndi-name>
      </ejb-local-ref>
      




      So from my servlet, I ought to be able to get a LocalHome reference with
      home = (FiboLocalHome) context.lookup("java:/comp/env/ejb/fibo/Fibo");


      However, the only way I'm able to get it is with context.lookup("local/Fibo"); which is not what I want at all. I want to be able to specify the local-jndi-name, not be stuck with whatever JBoss defaults to, which apparently is "local/EJBNAME."

      I know it's possible, because I did this a few months ago when I was messing around with JBoss. Haven't done anything since...so I'm not sure why I'm having this problem.

        • 1. Re: Setting the local-jndi-name of a local Session Bean
          Joan Horta  Tosas Novice

          You have an error in your code. You say you have:

          <ejb-local-ref>
           <description><![CDATA[Reference to the Fibo EJB]]></description>
           <ejb-ref-name>ejb/Fibo</ejb-ref-name>
           <ejb-ref-type>Session</ejb-ref-type>
           <local-home>tutorial.interfaces.FiboLocalHome</local-home>
           <local>tutorial.interfaces.FiboLocal</local>
          </ejb-local-ref>
          

          So from your servlet you must write:
          home = (FiboLocalHome) context.lookup("java:/comp/env/ejb/Fibo");
          

          not ejb/fibo/Fibo....