Your job for passivation: make your state passivatable!

When ejbPassivate() completes, every non-transient instance variable MUST be a reference to one of the following:
a Serializable object
a null value
a bean’s remote component or home interface, even if the stub class is not Serializable (in other words, you don’t have to worry about it!)
a bean’s local component or home interface, even if it’s not Serializable (again, you don’t have to worry)
a SessionContext object, even if it’s not Serializable
the bean’s special JNDI context, or any of its subcontexts
the UserTransaction interface (something you can get from your SessionContext—we’ll see that in the transactions chapter)
a resource manager connection factory (like, an instance of javax.sql.DataSource)
Note
You have to know these for the exam.
You might see a question that shows you a class and an ejbPassivate() method and asks you if it would work or not.
If the method is empty, you have to look at the instance variables to see if they’re all OK as they are.
Implementing ejbActivate() and ejbPassivate()
ejbPassivate()
Make sure your instance variables are ready for passivation. Most of the time, you probably won’t have any code in ejbPassivate(), simply because all of your instance variables meet the criteria defined on the previous page (e.g. reference to a SessionContext, or a bean’s component interface, or a Serializable object, etc.). ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access