Serialization and Deserialization and EJB calls

Discussions

EJB programming & troubleshooting: Serialization and Deserialization and EJB calls

  1. Hi, I have a small question:

    Suppose I deploy a Class A on the Client and I have also a Class A on serverside. They implement the same interface and are in the same package. But one method differs in implementation.

    When I call an EJB method with an instance of A and the EJB method calls the critical method, does the container ececute the method of the Class I deployed on Client side or the one on serverside? Meaning is the serverside class instantiated or not?

    Thanks

    Threaded Messages (6)

  2. The class loader on the server has no way to load defined on the client class and instanciate its object. Methods belong to classes, so the server version of the method will be executed (or deserialization exception will be thrown).
  3. Hi,

    interesting, I made a try now on WAS 6.0. I used an interface and two different classes, one on client and one on serverside. both implemented the interface and had an execute method implemented and they printed out different strings. Result: WAS executed the client side version!!!
    Seems like the complete class is serialized and deserialized meaning not only the state variables but also the complete code. Is this due to my approach with interfaces?!

    Thanks, T.
  4. What is the client?[ Go to top ]

    Is your client a servlet? Are you on a single machine?
    If yes, WAS will have only one JVM and this JVM is shared between web and EJB containters. So, once the client version of the class is loaded, its reused in EJB container
  5. What is the client?[ Go to top ]

    Hi, it is a remte client. I even use Sun JVM on clientside so they are definately seperated. It is a standalone client, where my command target is a Stateful Session Bean. I forgot one detail! actually the container had access to the command class as I also deployed it. So most likely the container loaded this class then.

    Maybe we can clarify it that way: my assumption, that the whole class is transfered - meaning with code and not only the state - is this wrong or right?

    Thomas
  6. What is the client?[ Go to top ]

    I am quite sure that the classes are not transfered. Otherwise you would never get ClassDefNotFound exception during deseralization. I guess if there are two different classes with the same package/name, the class loader just loads the first one it gets
  7. What is the client?[ Go to top ]

    I did not retest as I proceeded with a DTO pattern but I think you're right considering that you can get an NoClassDefNotFound exception, it must try to load a class. On the other hand, transfering the whole class would be pretty inefficcient.