title: Exception while deserialization
body: <p>I am trying to deserialize a class which is implementing the serializable interface and extending the class which is not serializable.</p>
  
  <pre><code>/**
  * 
  */
  package com.test;
  
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.Serializable;
  
  
  public class SerializationTest  implements Serializable {
  
  /**
   * 
   */
  private static final long serialVersionUID = -1324438308227634614L;
  
  class Papa{
      Papa(){
          System.out.println("Papa called..");
      }
  }
  class Student extends Papa implements Serializable{
  
      /**
       * 
       */
      private static final long serialVersionUID = 8667392485783922740L;
  
      String name;
      int id;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      /**
       * 
       */
      public Student() {
          System.out.println("Constructor called");
      }
  
  }
  
  public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
      Student arvind = new SerializationTest().new Student();
      arvind.setName("Arvind");
      arvind.setId(123);
  
      serialize(arvind);
      System.out.println("Serialization done..");
      deserialize();
  }
  
  /**
   * @throws IOException 
   * @throws FileNotFoundException 
   * @throws ClassNotFoundException 
   * 
   */
  private static void deserialize() throws FileNotFoundException, IOException, ClassNotFoundException {
  
      ObjectInputStream ois = new ObjectInputStream(new FileInputStream("tests.txt"));
  
      Student arvind = (Student)ois.readObject();
      System.out.println("Deserialize name - " + arvind.getName());
      System.out.println(arvind.getId());
      ois.close();
  
  }
  
  /**
   * @param arvind
   * @throws IOException
   * @throws FileNotFoundException
   */
  private static void serialize(Student arvind) throws IOException, FileNotFoundException {
      ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("tests.txt"));
  
      oos.writeObject(arvind);
      oos.flush();
      oos.close();
  }
  }
  </code></pre>
  
  <p>I am getting the below exception - </p>
  
  <pre><code>Exception in thread "main" java.io.InvalidClassException: com.test.SerializationTest$Student; no valid constructor
  at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(Unknown Source)
  at java.io.ObjectStreamClass.checkDeserialize(Unknown Source)
  at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
  at java.io.ObjectInputStream.readObject0(Unknown Source)
  at java.io.ObjectInputStream.readObject(Unknown Source)
  at com.test.SerializationTest.desseialize(SerializationTest.java:88)
  at com.test.SerializationTest.main(SerializationTest.java:75)
  </code></pre>
  
  <p>I have followed the answer of <a href="https://stackoverflow.com/questions/9747443/java-io-invalidclassexception-no-valid-constructor">java.io.InvalidClassException: no valid constructor</a> by making the default constructor but it also did not help.</p>
  
  <p>Any suggestion, help is much appreciated.</p>