Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Which objects or classes cannot be serialized? 'not serializable' error

Thread view: 
Will - 17 Feb 2006 11:10 GMT
I have a 'not serializable error' on sessions in a srevr cluster
problem
(the clustered servers are sharing session data and whinge that some
of it cannot be serialized, - I have to solve this problem somehow)
and want to find a list of classes that cannot be serialized so
I can find out just what is not serializing in my clustered session
data.
Its a negative, so not easy to search - I know I could look at every
java
class to see if its serializable but that would take 3 years hard work.

Is there a common list somewhere or some overriding simple principle
that
would tell me that something is probably not serializable?
John C. Bollinger - 18 Feb 2006 03:19 GMT
> I have a 'not serializable error' on sessions in a srevr cluster
> problem
> (the clustered servers are sharing session data and whinge that some
> of it cannot be serialized, - I have to solve this problem somehow)

[...]

> Is there a common list somewhere or some overriding simple principle
> that
> would tell me that something is probably not serializable?

Sure.  If it's a Java object, then it's probably not Serializable.
Really.  Serializability is the exception, not the rule.

More practically, no object can be serialized (via Java's built-in
mechanism) unless its class implements the Serializable interface.
Being an instance of such a class is not a sufficient condition,
however: for an object to be successfully serialized, it must also be
true that all non-transient references it holds must be null or refer to
serializable objects.  (Do note that that is a recursive condition.)
Primitive values, nulls, and transient variables aren't a problem.
Static variables do not belong to individual objects, so they don't
present a problem either.

Some common classes are reliably serialization-safe.  Strings are
probably most notable here, but all the wrapper classes for primitive
types are also safe.  Arrays of primitives are reliably serializable.
Arrays of reference types can be serialized if all their elements can be
serialized.

Signature

John Bollinger
jobollin@indiana.edu

Paulus de Boska - 18 Feb 2006 12:35 GMT
The index of the Java Developers Almanac shows you the classes that
implement Serializable. You could also write a program to scan the
documentation files for 'implements Serializable' and then some.
billreyn@gmail.com - 19 Feb 2006 11:27 GMT
Thanks for the info about serializable objects, I
am going to scan my error log now to find out
just which session data objects never made it
across the network on my app server.
I  hope that this non-serializable session data
(in a cluster) is not important and I can 'transient'
it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.