I am using Netbeans 6.8 and Glassfish v3.0.
I created an ejb module and created entity classes from database and then created stateless session bean with remote interface. Say eg.
@Remote
public interface customerRemote{
public void add(String name, String address);
public Customer find(Integer id);
}
@Stateless
public class customerBean implements customerRemote{
//implementations of methods
}
Then i created a new web application. But now how do i access remote ejb’s in my web application. I could lookup a bean with jndi name but what i want to know is, what type of object it will return? How do i typecast it in customerRemote? I don’t have any class named customerRemote in my web application. So, how do i do it? Also, what about the entity class Customer? There is no such class named Customer in my web application also. All ejb’s and entity classes are in separate ejb module. Please help me 🙁
Your web application must depend on a library that contains these classes and interfaces. Then you will be able to import the interface and typecast as usual. You have two approaches:
All in one jar. This seems to be what you have now. In this case your web app needs to depend on this jar.
Split API and implementation. A better approach is to split your ejb module in two jars: one jar
myModule-apicontains the classes that belong to the API of your module. In this case that would becustomerRemoteandCustomer. And another jarmyModule-implcontains the implementation (the implementation depends on the API of course). Then in your web app, you only need to depend on the API which is inmyModule-api.