1
votes

I was trying to serialized a class (DTO) to be used in send and receive in flows.My DTO class is not in the same module as flows. I am getting the below errors

1.With @CordaSerializable annotation , My DTO class is not getting serialized and it is throwing

java.io.NotSerializableException: Class "class com.e_mobility.dto.dashboard.DashboardDTO" is not on the whitelist or annotated with @CordaSerializable
  1. With manual whitelisting like below

    class CustomSerializationWhiteList : SerializationWhitelist { override val whitelist: List<Class<*>> = listOf(DTO::class.java) }

I am getting this error during runtime

 net.corda.core.serialization.internal.MissingSerializerException: Unable to create an object serializer for type class com.e_mobility.dto.dashboard.DashboardDTO:
Mandatory constructor parameters [arg0, arg1, arg2, arg3, arg4, arg5, arg6] are missing from the readable properties []
Either provide getters or readable fields for [arg0, arg1, arg2, arg3, arg4, arg5, arg6], or provide a custom serializer for this type

Please help me to resolve this error. (edited)

1

1 Answers

0
votes

As you are creating a custom type, did you check that all the needed requirements are fulfilled in your class? The annotation alone might be not enough. From the related Corda documentation about serialization with custom types:

  • The class must be compiled with parameter names included in the .class file. This is the default in Kotlin but must be turned on in Java using the -parameters command line option to javac
  • The class must be annotated with @CordaSerializable
  • The declared types of constructor arguments, getters, and setters must be supported, and where generics are used, the generic parameter must be a supported type, an open wildcard (*), or a bounded wildcard which is currently widened to an open wildcard
  • Any superclass must adhere to the same rules, but can be abstract
  • Object graph cycles are not supported, so an object cannot refer to itself, directly or indirectly