Featured Post

Scalability Techniques

Scalability is about the capability of a system to manage the increase workload of a system without causing qualities impact (i.e. perfo...

Wednesday, June 13, 2012

Remote Stateless Session Beans, Entity Beans and Serialization

Let's suppose you have an enterprise method of a Remote Stateless Session EJB like: public void save(Contact contact). Contact is an entity beans that must be a Serializable class.
Contact class needs to be serializable because a Remote Stateless Session EJB uses RMI protocol to communicate over network and RMI uses serialization to pass objects between JVMs.
If you don't make Contact a Serializable class, an exception may occur: java.io.NotSerializableException, when you invoke the enterprise method.
public interface ServiceContactEJBRemote {

 public void save (Contact contact);
public class ServiceContactEJB implements ServiceContactEJBRemote {

 @PersistenceContext(unitName = "serviceContact")
 private EntityManager entityManager;

 public void save(Contact contact) {


public class Contact implements Serializable{

 private int id;
 private String number;
 private String type;


No comments :

Post a Comment