Featured Post

NoSQL use cases

Here are a simple summary of use cases for Cassandra, MongoDB and Redis MongoDB Storing Log Data Speed is the primary perfor...

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