title: EJB 3 Stub generation
body: <p>I have an ejb-3 compatible ejb, say</p>
  
  <pre><code>@Remote
  interface Hai{
       String sayHai();
  }
  Stateless(name = "xxx", mappedname="yyy")
  public class HaiImpl implements Hai{
      public String sayHai(){
          return "Hai";
      }
  }
  </code></pre>
  
  <p>And I need to generate stub for this EJB. but I dont want to use websphere tool or maven tool.
  Is there any way to generate stub using jdk?</p>
  
  <p>When you create remote client</p>
  
  <pre><code> Hai hai = (Hai)ctx.lookup("yyy#com.zz.Hai");
   System.out.println(hai.sayHai());
  </code></pre>
  
  <p>will work in weblogic or jboss, but in websphere, even it is ejb 3 you need to write like this</p>
  
  <pre><code>Object o = ctx.lookup("yyy");
  Hai hai =    (Hai)javax.rmi.PortableRemoteObject.narrow(o,Hai.class);
  System.out.println(hai.sayHai());
  </code></pre>
  
  <p>In this case, if the stub is not presents at the client it will throw exception, there is a way to generate stub using websphere ejb stub generater tool. But I dont want to use any platform specific tools.</p>