Improve error messages for non-composable types


When the serializer factory is asked to create an object serializer for a type that cannot automatically be serialized, an exception is thrown:

This exception is thrown when we try to create an ObjectSerializer for a type which has been marked as NonComposable, using the ObjectSerializer.make method. However, the error message is confusing, and fails to convey some important information.

There are three conditions under which a type may be marked as NonComposable during type analysis:

1) It is impossible to identify a unique deserialization constructor for the type, i.e. there are multiple constructors, and none is annotated with @ConstructorForDeserialization.
2) The unique deserialization constructor has parameters for which the type does not have corresponding readable properties, e.g. a parameter not marked as val or var for which there is no matching getter method or readable field.
3) One or more of the properties of the type is of a type which is itself NonComposable.

It would be much more helpful if the error message thrown when attempting to create an ObjectSerializer for a NonComposable type explained why the type was NonComposable, e.g.

This can be done by adding two String fields to the LocalTypeInformation.NonComposable type, reason and remedy, which can then be used to build a meaningful error message. These fields should be populated during type analysis.

It would also be helpful if this error message could list out the fully-qualified classnames of all of the custom serializers registered with the current serialization context, together with details of their classloader, since a common cause of this exception is failure to load some custom serializer (or one of its dependencies) from a CorDapp jar at runtime.


Dan Newton




Epic Link




Engineering Teams


Fix versions

Affects versions

Ported to...

Corda 4.3
Corda Enterprise 4.2

Story Points / Dev Days


Build cut