Why does EJB need to implement a serializable interface?

Is there a reason why EJB classes should be serializable? I heard that this is due to the fact that RMI is used under the hood. I know how RMI (remote method call) works, there is a remote object registered on the server side, and only the remote object is sent to the client to the client, not the whole object.

Thus, in RMI applications, the methods of the remote object must take arguments and return values ​​that can be serialized because they are sent over the network, but not the remote object itself.

+4
source share
1 answer

The reason that the old EJBS J2EE style that implements javax.ejb.EntityBean , javax.ejb.SessionBean and javax.ejb.MessageDrivenBean must be serializable is historical. The original interface is javax.ejb.EnterpriseBean that these extensions themselves extend java.io.Serializable . In the earliest days of EJB, this was thought to be necessary to facilitate the movement of beans between JVMs.

All the practical reasons that EJBs actually implement Serializable have disappeared by the time the EJB 2.0 specification was published.

The introduction of EJB 3 removed the requirement for any of these interfaces (and subsequently java.io.Serializable) to be implemented.

EJB, EJB 2.0 , EJB . - .

EJB 3.x.

+8

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


All Articles