title: read java.security.key stored as object inside a file which is in jar
body: <p>I saved a PublicKey instance in a file using ObjectOutputStream. This file is then stored inside a jar file which is then loaded by JBoss. I'm trying to read this file but it throws me an exception telling that it's not serializable. 
  Here is the code :</p>
  
  <p>InputStream input = KeyLoader.class.getClassLoader().getResourceAsStream(resource);
  ObjectInputStream objectInputStream = new ObjectInputStream(input);
  Object obj = objectInputStream.readObject();
  Key output = (Key) obj;
  objectInputStream.close();
  return output;</p>
  
  <p>which throws me this exception 
  An exception occurred: java.io.NotSerializableException</p>