0

I got an object which should be serialized. Atm I let it implement Serializable but in runtime I get an

Failed to marshal object with optimized marhshaller:{ $heresAhugeString$ }
Failed to serialize object: { $alsoHugeString$ } 
java.io.IOException: Externalizable class doesn't have default constructor: interface java.io.Externalizable 
Externalizable class doesn't have default constructor: interface java.io.Externalizable
java.io.Externalizable.<init>()   

The last exception (java.io.Externalizable.() comes infinite times) I try to find the non-serializable field but I only can see that it throws exception at serializing a ConcurrentHashMap. I know this aren't much information but the complete stacktrace is quite big. Any tips how to find out which field in the map is responsible for non-serialization ? Or which information should I add ? Regards

  • Shouldn't this help you - `Externalizable class doesn't have default constructor` – Abubakkar Mar 14 '17 at 15:13
  • But I don't know which class is meant... – Matthias Harter Mar 14 '17 at 15:17
  • @Abubakkar is correct. When serializing, the default constructor is needed to instantiate the serialized class. You don't have one. – Dakoda Mar 14 '17 at 15:18
  • The exception doesn't 'come infinite times'. It comes once for every key or value in the map. Look at the end of the stack trace. – user207421 Mar 14 '17 at 15:24
  • @EJP I think not. But could be possible. In the debugger there's a line cause = {NoSuchMethodException@129509} and it has got a child which has the same line and so on ... (the id is always the same) – Matthias Harter Mar 14 '17 at 15:30

1 Answers1

-1

I don't know what type of deserialization you are doing, but if you don't need use this field after unmarshalling, then you must set it as transient.

The transient java keyword can be used if your are use the Java Serialization, or @Transient if you are using JPA, or even @JsonIgnoreProperties if you are using Jackson

rvillablanca
  • 1,606
  • 3
  • 21
  • 34