I have an object in my Spring application which I want to persist whenever some new data is written into it.
This is my object,
public class MessageBroker implements Serializable{
    private List<Message> backbone;
    private Map<String, List<Message>> messagesReceived;
    private Map<String, List<Message>> messagesSent;
    public MessageBroker(){
        backbone = new ArrayList<>();
        messagesReceived = new ConcurrentHashMap<>();
        messagesSent = new ConcurrentHashMap<>();
    }
..........
Now in the send method on the object, I have this,
public void send(Message message){
  .........
  FileOutputStream fileOutputStream = null;
        ObjectOutputStream objectOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream("./data/store.ser");
            objectOutputStream = new ObjectOutputStream(fileOutputStream);
            objectOutputStream.writeObject(this);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
This is my Message object,
public class Message implements Serializable{
    @Getter @Setter
    private String senderId;
    @Getter  @Setter
    private String receiverId;
    @Getter  @Setter
    private String mediaId;
}
I get the following error,
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.MessageBroker
How am I getting this since I've already implemented Serializable.