How to access beans object from remote client?

I have this on 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 JVMs):

  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, the getPerson () method from my EJB, which returns an object of type Person, how will my client understand that Person is a class?

Do I have to re-write the Person class again in my client (as well as the HelloServiceRemote class) so that it can understand what Person is? Or do I need to include an Eyb project in my client project?

+3
source share
1 answer

You must enable the client-side EJB jar containing interfaces, entities, and other utility classes.

Entity Beans , http://www.ibm.com/developerworks/websphere/library/bestpractices/ejbs_access_entity_bean.html

+2

Source: https://habr.com/ru/post/1767641/


All Articles