Featured Post

Event Sourcing Video from Michael Ploed

Event Sourcing I want to share a great video I found few days ago that describes very well what Event Sourcing is.

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