My application server is WebSphere Application Server V8. I have a session scoped managed bean in which I have injected EJB (EJB 3.0) using @EJB annotation. EJB is stateless.
@ManagedBean
@SessionScoped
public class MyBean extends BaseBackingBean implements
Serializable {
@EJB
private IDetails custInfo;
I was analyzing the session data and noticed NotSerializableException
java.io.NotSerializableException: com.ejb.EJSLocal0SLDetailsImpl_081f812d at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184) at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1537) at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1502) at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1420) at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178) at
Now I tried to mark the EJB as transient and it works fine without throwing NotSerializableException exception.
@EJB
private transient IDetails custInfo;
Is this correct implementation or what can be alternate solution?
I have referred Should EJBs be instance variables and marked as transient in JSF Managed Beans? where it is mentioned that marking EJB as transient is not required; then what can be wrong?