EJB local reference

Discussions

EJB design: EJB local reference

  1. EJB local reference (3 messages)

    when i am trying to get local reference of my bean from another bean , i am getting naming exception in the look up.Is getting local reference legal from another bean , if yes then how it should be done.
    thanx
    kapil

    Threaded Messages (3)

  2. EJB local reference[ Go to top ]

    Are you running both beans in the same jar-file ?

    I believe you can only use the local interface to reference a bean if both are in the same jar file.

    Hope this helps
  3. vendor[ Go to top ]

    which vendor do you use?
  4. EJB local reference[ Go to top ]

    Actually Bert, they do not need to be in the same jar file.
    As per EJB 2.0
    For a client to call the Local interface, they must be running in the same JVM as the JVM that the EJB exists in. This means that not only an EJB can call a local EJB , Servlets or JSPs can also call the EJB via it's local interface if they are packaged together as part of same application.

    You can check the ejb-jar.xml deployment descriptor. It shud read something like this:
      <entity>
        <ejb-name>Emp</ejb-name>
        <local-home>ejb.cmplocal.EmpHome</local-home>
        <local>ejb.cmplocal.Emp</local>
        <ejb-class>ejb.cmplocal.EmpBean</ejb-class>
        <cmp-version>2.x</cmp-version>
        <abstract-schema-name>Emp</abstract-schema-name>
        .
        .
        .

    Also in the lookup for local beans, we do not have to use the PortableRemoteObject. The lookup shud be something like:
    try
      {
        Context ctx = new InitialContext();
        Object o = ctx.lookup("java:comp/env/LocalEmp");
        EmpHome empHome = (EmpHome)o;
        return empHome.findByDeptno(getDeptno());
      }

    What is the exact exception you are getting?