Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializable

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know if byte[] is serializable. Also how to i check if the entire obejct is serializable? I have an object which implements serializable, but at run time am getting NotSerializableExceptionexception. This happens only when I tun the app in clustered mode using apache and tomcat.

If I tun it in non clustered mode....everything looks fine.



An yhelp on this...pls
[ September 24, 2006: Message edited by: Mary Cole ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message tells you the nonserializable class:

java.io.NotSerializableException: com.icon.ntral.form.IrEnt$2

That's the second anonymous class defined in the class com.icon.ntral.form.IrEnt .
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is my code in the inner class ...how do i make it serializable...The parent class implements serializable

Pls advice
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd just have to make it into a named class -- i.e., define it inside the method or inside the class, rather than as an anonymous class, or even as a new top-level class (since it doesn't seem to need access to the enclosing class for anything.) Once you give it a name, then it's obvious how to declare that it implements Serializable.
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can U pls elaborate on this....may be a sample code would help....pls its urgent

The Factory defined above is of type org.apache.commons.collections.Factory
[ September 26, 2006: Message edited by: Mary Cole ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One option would just be this:

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot it worked
 
Abhijeet Joshi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
God bless you guys! I had the same problem with the LazyList factory (inner class). Your postings were spot on.
Thanks a ton,
Abhijeet
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic