why I'm getting NotSerializableException exception though I've implemented 'Serializable'

后端 未结 3 413
抹茶落季
抹茶落季 2021-01-28 12:18

I\'ve implemented Serializable in class \'userInfo\'. Still I\'m getting exception. Here\'s the output console -

java.io.WriteAbortedException: writing aborted;         


        
相关标签:
3条回答
  • 2021-01-28 12:19

    Without seeing your code, it's hard to know for sure, but the cause of this is almost always that your class has a field that is not serializable (or that contains an object that contains a field, ...). Everything in an object, including everything that the object references and everything that those objects reference, must be serializable to avoid the exception.

    0 讨论(0)
  • 2021-01-28 12:28

    why I'm getting NotSerializableException exception though I've implemented 'Serializable'

    You haven't.

    java.io.NotSerializableException: chatservernazmus.User public class userInfo implements Serializable{ public class User{

    The User class must be serializable as well.

    0 讨论(0)
  • 2021-01-28 12:41

    Pass -Dsun.io.serialization.extendedDebugInfo=true to the JVM for tracking the exact cause for NotSerializableException.

    Eg: Add SET CATALINA_OPTS=%CATALINA_OPTS% -Dsun.io.serialization.extendedDebugInfo=true in the startup.bat

    0 讨论(0)
提交回复
热议问题