Hello,
I serialize an Ejb3Configuration. When I deserialize it, it return me a NullPointerException
Can anyone help me to find the solution
thanks
Code:
private void serializeEjb3Configuration(Column acfg) {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(FILE_SERIALIZE);
oos = new ObjectOutputStream(fos);
oos.writeObject(acfg);
oos.flush();
// log.info("Ejb3Configuration is serialized in : " +
// FILE_SERIALIZE);
} catch (IOException ioe) {
log.info("Error : can't serialize the Ejb3Configuration in : "
+ FILE_SERIALIZE);
ioe.printStackTrace();
} finally {
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Code:
private Column deserializeEjb3Configuration() {
Column acfg = null;
ObjectInputStream ois = null;
FileInputStream fis = null;
try {
fis = new FileInputStream(FILE_SERIALIZE);
ois = new ObjectInputStream(fis);
try {
acfg = (Column) ois.readObject();
} catch (ClassNotFoundException e) {
log.info("Error : can't read the Ejb3Configuration from : "
+ FILE_SERIALIZE);
e.printStackTrace();
}
} catch (IOException ioe) {
log.info("Error : can't deserialize the Ejb3Configuration from : "
+ FILE_SERIALIZE);
ioe.printStackTrace();
} finally {
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return acfg;
}
Code:
java.lang.NullPointerException
at org.hibernate.mapping.Column.hashCode(Column.java:202)
at java.util.AbstractList.hashCode(AbstractList.java:527)
at org.hibernate.mapping.Table$ForeignKeyKey.hashCode(Table.java:69)
at java.util.HashMap.putForCreate(HashMap.java:413)
at java.util.HashMap.readObject(HashMap.java:1031)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)