title: Remote EJB lookup in Websphere (and Weblogic/JBoss)
body: <p>I have a EJB class that is used for searching,</p>
  
  <pre><code>@Local(ILuceneEmployeeSearchManagerLocal.class)
  @Remote(ILuceneEmployeeSearchManagerRemote.class)
  public class LuceneEmployeeSearchManager implements ILuceneEmployeeSearchManagerLocal, ILuceneEmployeeSearchManagerRemote{
  ....
  }
  </code></pre>
  
  <p>There is another class in a WAR project in the same EAR, which accesses this,</p>
  
  <pre><code>public class EmployeeAccessor {
  
      private ILuceneEmployeeSearchManagerRemote searcher;
  
      public EmployeeMstAccessor() {
  
          Context ic = null;
          try {
              Properties props = new Properties();
              props.put(Context.INITIAL_CONTEXT_FACTORY, "&lt;WHAT_TO_PUT_HERE&gt;");
              props.put(Context.PROVIDER_URL, "iiop://127.0.0.1:9083");
              ic = new InitialContext(props);
              this.searcher = (ILuceneEmployeeSearchManagerRemote) ic
                  .lookup("&lt;WHAT_TO_PUT_HERE?&gt;");
          } catch (Exception e) {
              e.printStackTrace();
              throw new RuntimeException(e);
          }
      }
  
      ....
  
  }
  </code></pre>
  
  <p>This is working perfectly, when I was performing local lookups using JNDI. Due to some
  requirements, it is now necessary to deploy the EAR in multiple APs, (both in clustered and non-clustered environments). Also, the application server used will be same across APs, but not necessarily Websphere, i.e all of the APs may be using JBoss/Websphere/Weblogic. </p>
  
  <p>My question is there an implementation independent way of looking up and invoking remote EJBs ? Something that will work for Websphere, Weblogic or JBoss environments (homogeneous environments).</p>
  
  <p>My second question is assuming the AP servers are running Websphere (in clustered or non-clustered environment), say I want EmployeeAccessor in all of the AP servers to be using the LuceneEmployeeSearchManager EJB deployed in AP01 (ip:x.x.x.x, port:yy), how do I configure it ? Is it necessary to give the full JNDI name (including cell name and node name for websphere) ? What are the proper values for INITIAL_CONTEXT_FACTORY ? and what is the correct JNDI lookup syntax ?</p>
  
  <p>Thank you for any help :)</p>