madbean

Why does javax.ejb.EnterpriseBean extends java.io.Serializable?

26 Mar 2003

So, I was asked wtf javax.ejb.EnterpriseBean extends java.io.Serializable today. I have no idea! EnterpriseBean is the super-interface of EntityBean, MessageDrivenBean and SessionBean, so your bean-implementation classes are always serializable. Why is that necessary?

Some digging was in order.

I can naively understand why a Stateful SessionBean would be serializable; so that a container could "persist" it during activation/passivation, or move it around the nodes of a cluster. But that is not the modus operandi of EntityBeans... they have CMP or their store/load methods for that.

I couldn't find any justification why EnterpriseBean is serializable in the EJB2.0 Spec (ejb-2_0-fr2-spec.pdf); it talks about how SessionBean activation/passivation uses serialization, but not a thing on Entity nor MessageDriven beans.

This is not a big issue... but I'm left scratching my head...

  • Home
  • Blog