Question

i have this in the server:

class Person{...}

and

@Stateless
public class HelloServiceBean implements HelloServiceLocal, HelloServiceRemote {
    public Person getPerson(String name) {
        return new Person(name);
    }
}

And i have this in my client (in some different JVM):

  public static void main(String[] a) throws Exception{
        String name = "java2s";
        HelloServiceRemote service = null;

        service = (HelloServiceRemote)new InitialContext().lookup("HelloServiceBean/remote");
        Person p = service.getPerson(name));
   }

When i need to call, for example, getPerson() method from my EJB, which return an object of type of Person, how my client is going to understand that Person is a class ?

Do i have to re-write the Person class another time in my client (and also the HelloServiceRemote class), so it can understand what is a Person ? Or do i have to include the Ejb project into my client project ?

Was it helpful?

Solution

You have to include jar of EJB project at client side containing Interfaces, Entities & other utility classes used.

But exposing Entity Beans at client side is not preferable, you can get more information regarding this at http://www.ibm.com/developerworks/websphere/library/bestpractices/ejbs_access_entity_bean.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top