• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

NotSerializableException for a POJO

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've a POJO of which i create an ArrayList<myPOJO>

I'm storing it in a session attribute my ArrayList<myPOJO>

Considering above scenario....

Rarely, i get NotSerializableException refering to myclass i.e. myPOJO

Is it related to following.....?



Thanks,
Aditya Kanitar.
 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your class serializable? If not, it should be to be stored in the session.
 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I haven't implemented serializable to my POJO.... But is it mandatory that the class MUST be implemented with Serializable interface...??

I also have some other POJO's which have been set in Session attribute as List of POJO objects.... But only one of my class gives this exception....
 
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sending this arraylist of POJO Objects in OutputStream connecting to remote Client?... If its, since these objects has also to be sent serialized in the stream, it has to implement "Serializable" interface
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rarely, i get NotSerializableException refering to myclass i.e. myPOJO



The exact stack trace would tell you more than guessing. Note that servlet containers are allowed to serialize a session to disk whenever they want to - at that point your POJO would cause that exception.

Bill
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic