title: How to serialize ObservableList
body: <p>I am working on a <strong>javaFx</strong> project where we have to use <code>ObservableList</code> to add Listners. <code>ObservableList</code> includes Model of persons. But I want to <strong>store</strong> the whole <code>ObservableList</code> Object in a file through serialization. But it <strong>gives me an Exception</strong>.
  I also implimented Serialization on the object Model but no luck. Is there any method to serialize <strong>ObservableList</strong>?</p>
  
  <h2><strong>EmployeeModel</strong></h2>
  
  <pre><code>package com.company.Model;
  
  import javax.persistence.*;
  import java.io.Serializable;
  
  /**
   * Created by Sunny on 1/8/2016.
   */
  @Entity
  @Table(name = "Employee", schema = "", catalog = "PUBLIC")
  public class EmployeeEntity implements Serializable {
      private String empId;
      private String empAddress;
      private String empNumber;
      private String empFirstName;
      private String empLastName;
  
      public EmployeeEntity(String empId, String empAddress, String empNumber, String empFirstName, String empLastName) {
          this.empId = empId;
          this.empAddress = empAddress;
          this.empNumber = empNumber;
          this.empFirstName = empFirstName;
          this.empLastName = empLastName;
      }
  
      public EmployeeEntity() {
  
      }
  
      @Id
      @Column(name = "emp_ID")
      public String getEmpId() {
          return empId;
      }
  
      public void setEmpId(String empId) {
          this.empId = empId;
      }
  
      @Basic
      @Column(name = "emp_address")
      public String getEmpAddress() {
          return empAddress;
      }
  
      public void setEmpAddress(String empAddress) {
          this.empAddress = empAddress;
      }
  
      @Basic
      @Column(name = "emp_number")
      public String getEmpNumber() {
          return empNumber;
      }
  
      public void setEmpNumber(String empNumber) {
          this.empNumber = empNumber;
      }
  
      @Basic
      @Column(name = "emp_firstName")
      public String getEmpFirstName() {
          return empFirstName;
      }
  
      public void setEmpFirstName(String empFirstName) {
          this.empFirstName = empFirstName;
      }
  
      @Basic
      @Column(name = "emp_lastName")
      public String getEmpLastName() {
          return empLastName;
      }
  
      public void setEmpLastName(String empLastName) {
          this.empLastName = empLastName;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
  
          EmployeeEntity that = (EmployeeEntity) o;
  
          if (empId != null ? !empId.equals(that.empId) : that.empId != null) return false;
          if (empAddress != null ? !empAddress.equals(that.empAddress) : that.empAddress != null) return false;
          if (empNumber != null ? !empNumber.equals(that.empNumber) : that.empNumber != null) return false;
          if (empFirstName != null ? !empFirstName.equals(that.empFirstName) : that.empFirstName != null) return false;
          if (empLastName != null ? !empLastName.equals(that.empLastName) : that.empLastName != null) return false;
  
          return true;
      }
  
      @Override
      public int hashCode() {
          int result = empId != null ? empId.hashCode() : 0;
          result = 31 * result + (empAddress != null ? empAddress.hashCode() : 0);
          result = 31 * result + (empNumber != null ? empNumber.hashCode() : 0);
          result = 31 * result + (empFirstName != null ? empFirstName.hashCode() : 0);
          result = 31 * result + (empLastName != null ? empLastName.hashCode() : 0);
          return result;
      }
  }
  </code></pre>
  
  <h2><strong>Serialization</strong></h2>
  
  <pre><code> public void write(ObservableList&lt;EmployeeEntity&gt; personObservalble) {
          try {
              // write object to file
              FileOutputStream fos = new FileOutputStream("Objectsavefile.ser");
              ObjectOutputStream oos = new ObjectOutputStream(fos);
              oos.writeObject(personsObservable);
              oos.close();
  
  
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <h2><strong>Exception</strong></h2>
  
  <pre><code>java.io.NotSerializableException: com.sun.javafx.collections.ObservableListWrapper
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
      at FileWriter.write(FileWriter.java:14)
      at Main.main(Main.java:12)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  
  Process finished with exit code 0
  </code></pre>