I am trying to access a remote EJB3 bean from a client which runs on a separate JVM using JNDI lookup. Following are my bean classes:
@Path("/payment/")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@Local({ PaymentWebServiceLocal.class })
@Remote({ PaymentWebServiceRemote.class })
@Stateless(mappedName = "ejb/PaymentWebService")
public class PaymentWebServiceImpl implements PaymentWebServiceLocal,PaymentWebServiceRemote {
private static final Logger logger = Logger.getLogger(PaymentWebServiceImpl.class);
@POST
@Path("/processpayment")
public PaymentResponse processPayment(PaymentRequest request) {
//do something
}
The remote interface of the Bean is as follows
@Remote
public interface PaymentWebServiceRemote {
public PaymentResponse processPayment(PaymentRequest request);
}
Now, I lookup the EJB using JNDI to invoke the processPayment() method from the remote client as follows
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, t3:\\);
Context ctx = new InitialContext(env);
return ctx.lookup("ejb.PaymentWebService#test.webservice.payment.service.PaymentWebServiceRemote");
What I don't understand is that the client do not know about the remote PaymentWebServiceRemote interface. It is in another server with the EJB Bean code. Do I have to take a copy of this interface to client code as well? Or is there some way of creating a client EJB jar with the remote interface for client to use in EJB3 (like we did in EJB2)?
Any help is appreciated.