Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NotSerializableException for a POJO  RSS feed

 
Aditya Kanitkar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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....
 
Ram Narayan.M
Ranch Hand
Posts: 247
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!