问题
I have tired to add @Id for primary key declaration in schema. build and ran successfully. But its shows as Class org.hibernate.AnnotationException is not annotated or on the whitelist, so cannot be used in serialization Serialization trace: cause (rx.exceptions.OnErrorNotImplementedException) throwable (rx.Notification) . i added @corda serializable too. please help me out.
回答1:
The issue is as follows:
- Your code is throwing an
org.hibernate.AnnotationException
- The node is trying to send this exception back to the client over RPC, or to another node as part of a flow
- For security purposes, only whitelisted classes can be serialised and sent within flows or over RPC
- The exception class is not whitelisted, so a serialisation exception is thrown instead
Once you whitelist the exception class, it will be serialised and returned properly, allowing you to diagnose the underlying issue.
Adding classes to the whitelist
You can add classes to this whitelist by:
Adding the
@CordaSerializable
annotation to the class@CordaSerializable class MyClass
Adding it to the serialisation whitelist:
class TemplateSerializationWhitelist : SerializationWhitelist { override val whitelist: List<Class<*>> = listOf(MyClass::class.java) }
The serialization whitelist plugin's fully-qualified class name must then be added to a file called net.corda.core.serialization.SerializationWhitelist
in the src/main/resources/META-INF/services
folder.
来源:https://stackoverflow.com/questions/47633652/org-hibernate-annotationexception-is-not-annotated-or-on-the-whitelist