Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Passivation question

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the spec, what should the container do if a stateful session bean holds a non-null reference to non-serializable object (Socket, for instance) while passivating the bean? Any exception will be thrown?
[ February 15, 2005: Message edited by: Keerthi P ]
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
A session bean instance wont b passivated if it holds transaction context. Bean will throw exception if its holding a reference to an open socket connection.(system-level classes such as Thread, OutputStream and its subclasses, and Socket are not serializable).

If the variable(which is part of Session Beans conversational State)isn't serializable, then the serialization mechanism will throw an exception when it tries to serialize the variable. To avoid this, you can declare the variable to be transient.


Binoj V
 
Keerthi P
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. But any idea what exception will be thrown?
[ February 16, 2005: Message edited by: Keerthi P ]
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most probably, the NotSerializableException will be thrown.

P.S -> Will confirm it tomorrow though. I am feeling tooo sleepy today.
 
Keerthi P
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Here is what the spec has to say:
The spec does not mandate the container to use Java's Serialization for passivating session beans. The container can choose to use it but need not necessarily have to. Of course, Passivation and Serialization are NOT the same because unlike serialization, passivation does not bother to reset 'transient' fields.

Therefore it is upto the container to decide what to do if an instance field in not serializable. The spec does not stipulate any rules regarding this. If such case should arise, the container may log the problem, throw SYSTEM exception and destroy the bean instance. It may also even choose to reset the non-serialiable field to null or whatever during activation. The spec generally discourages the use of such fields. It simply won't be restored.
[ February 16, 2005: Message edited by: Keerthi P ]
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic