EJB 3 Stub generation

Viewed 9183

I have an ejb-3 compatible ejb, say

@Remote
interface Hai{
     String sayHai();
}
Stateless(name = "xxx", mappedname="yyy")
public class HaiImpl implements Hai{
    public String sayHai(){
        return "Hai";
    }
}

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?

When you create remote client

 Hai hai = (Hai)ctx.lookup("yyy#com.zz.Hai");
 System.out.println(hai.sayHai());

will work in weblogic or jboss, but in websphere, even it is ejb 3 you need to write like this

Object o = ctx.lookup("yyy");
Hai hai =    (Hai)javax.rmi.PortableRemoteObject.narrow(o,Hai.class);
System.out.println(hai.sayHai());

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.

2 Answers
Related