Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to handle non serializable objects during ejb passivation?

 
Krishan Chauhan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Krishan Chauhan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic