It's not a secret anymore!*
The moose likes EJB and other Java EE Technologies and the fly likes How to handle non serializable objects during ejb passivation? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to handle non serializable objects during ejb passivation?" Watch "How to handle non serializable objects during ejb passivation?" New topic
Author

How to handle non serializable objects during ejb passivation?

Krishan Chauhan
Ranch Hand

Joined: Mar 12, 2008
Posts: 32
Hi,

I am injecting javax.mail.Session using Resource annotation. As Session does not implement Serializable interface, I am getting NotSerializableException during ejbPassivate.



I am able to fix this by setting session to null in @PrePassivate method and then again looking up in @PostActivate method



Here we have to look up for Session again. Is there any better approach to fix this?


Thanks,
Krishan
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Hi...

i think it doesn't matter if we configure CallbackMethods if we want to use any Resources in EJBContainer..
or do you want to use only PropertyInjection?..
i think the PropertyInjection, SetterInjection and Through callback methods is all the same, and all of it offer ease way to getting resources that we want..
the important thing when we use one of that is we want use resources provided by EJBContainer..

Please correct me if i'm wrong...

Thanks..


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Krishan Chauhan
Ranch Hand

Joined: Mar 12, 2008
Posts: 32
Hi Leonardo,

I dont want to lookup again for Session in callback method when I have injected it. Is there any way to configure this?
Here I am injecting and then looking up, so I am not getting full advantage of injection.

Thanks,
Krishan
 
wood burning stoves
 
subject: How to handle non serializable objects during ejb passivation?
 
Similar Threads
Observing Stateful Session Bean @PrePassivate and @PostActivate
Sharing Objects Between Stateful Session Beans
Question on Lifecycle callbacks of Enterprise Beans
Security and Transactions within @PrePassivate & @PostActivate
ETS Question doubt 1