问题
I have a multimodule project similar to this one.
I'm using Corda 3.2, Spring Boot 2 without Kotlin and I have a set of Corda nodes running thanks to cordformation. I'm able to connect successfully to a node from my Spring Boot app, but getting into to trouble when trying to, for example, get nodeInfo.
I saw a similar question here. But the answer to "clear caches" there is confusing to me. Does it mean to clear gradle's cache? How would that help?
Here's my stack trace:
com.esotericsoftware.kryo.KryoException: java.lang.IllegalArgumentException: Privacy salt should be 32 bytes.
Serialization trace:
legalIdentitiesAndCerts (net.corda.core.node.NodeInfo)
value (net.corda.core.utilities.Try$Success)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:144) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.read(CompatibleFieldSerializer.java:147) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.read(CompatibleFieldSerializer.java:147) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813) ~[kryo-4.0.0.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme$deserialize$$inlined$use$lambda$1$1.invoke(KryoSerializationScheme.kt:97) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme$deserialize$$inlined$use$lambda$1$1.invoke(KryoSerializationScheme.kt:37) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme.withContext(KryoSerializationScheme.kt:80) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme.access$withContext(KryoSerializationScheme.kt:37) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme$deserialize$$inlined$use$lambda$1.execute(KryoSerializationScheme.kt:95) ~[corda-node-api-3.2-corda.jar:na]
at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:61) ~[kryo-4.0.0.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme.deserialize(KryoSerializationScheme.kt:94) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$deserialize$1$1.invoke(SerializationScheme.kt:111) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.core.serialization.SerializationFactory.withCurrentContext(SerializationAPI.kt:66) ~[corda-core-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:111) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:86) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.core.serialization.SerializationFactory.asCurrent(SerializationAPI.kt:80) ~[corda-core-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl.deserialize(SerializationScheme.kt:111) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.RPCApi$ServerToClient$Companion.fromClientMessage(RPCApi.kt:360) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.client.rpc.internal.RPCClientProxyHandler.artemisMessageHandler(RPCClientProxyHandler.kt:256) ~[corda-rpc-3.2-corda.jar:na]
at net.corda.client.rpc.internal.RPCClientProxyHandler.access$artemisMessageHandler(RPCClientProxyHandler.kt:69) ~[corda-rpc-3.2-corda.jar:na]
at net.corda.client.rpc.internal.RPCClientProxyHandler$start$2.invoke(RPCClientProxyHandler.kt:197) ~[corda-rpc-3.2-corda.jar:na]
at net.corda.client.rpc.internal.RPCClientProxyHandler$start$2.invoke(RPCClientProxyHandler.kt:69) ~[corda-rpc-3.2-corda.jar:na]
at net.corda.client.rpc.internal.RPCClientProxyHandlerKt$sam$MessageHandler$6fb61eb3.onMessage(RPCClientProxyHandler.kt) ~[corda-rpc-3.2-corda.jar:na]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1003) ~[artemis-core-client-2.4.0.jar:2.4.0]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:50) ~[artemis-core-client-2.4.0.jar:2.4.0]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1126) ~[artemis-core-client-2.4.0.jar:2.4.0]
at org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:42) [artemis-commons-2.4.0.jar:2.4.0]
at org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:31) [artemis-commons-2.4.0.jar:2.4.0]
at org.apache.activemq.artemis.utils.actors.ProcessorBase$ExecutorTask.run(ProcessorBase.java:53) [artemis-commons-2.4.0.jar:2.4.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: java.lang.IllegalArgumentException: Privacy salt should be 32 bytes.
at net.corda.core.contracts.PrivacySalt.(Structures.kt:303) ~[corda-core-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.DefaultKryoCustomizer$PrivacySaltSerializer.read(DefaultKryoCustomizer.kt:197) ~[corda-node-api-3.2-corda.jar:na]
at net.corda.nodeapi.internal.serialization.kryo.DefaultKryoCustomizer$PrivacySaltSerializer.read(DefaultKryoCustomizer.kt:191) ~[corda-node-api-3.2-corda.jar:na]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) ~[kryo-4.0.0.jar:na]
... 33 common frames omitted
The privacy salt that needed to be 32 bytes long was 56 bytes for me.
回答1:
The reason for the error was not too new Gradle version. It came from the fact that my Spring Boot app had Guava dependency with version 26.0, but Corda 3.2 has version 21.0.
Related Stackoverflow question regarding this is In Corda, `KryoException: Encountered unregistered class ID` despite registering classes
回答2:
This error is due to Guava dependency version. I had version 27 and was facing this issue i changes version to 21 and it works...
Using corda 3.3
来源:https://stackoverflow.com/questions/52162347/using-corda-rpc-api-in-spring-boot-throws-illegalargumentexception