I tried migration from Corda Server to Spring Boot.I referred to Joel's Project(Corda official) in Kotlin but getting this exception when trying to use rpcOps.
RPCClientProxyHandler.artemisMessageHandler - RPC reply arrived to unknown RPC ID RpcRequestId(toLong=2111196934580277300), this indicates an internal RPC error.
[ERROR] 2018-02-02T07:54:05,227 [Thread-0 (ActiveMQ-client-global-threads)] client - AMQ214000: Failed to call onMessage
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:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.read(CompatibleFieldSerializer.java:147) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.read(CompatibleFieldSerializer.java:147) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813) ~[kryo-4.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme$deserialize$$inlined$use$lambda$1$1.invoke(SerializationScheme.kt:209) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme$deserialize$$inlined$use$lambda$1$1.invoke(SerializationScheme.kt:152) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme.withContext(SerializationScheme.kt:191) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme.access$withContext(SerializationScheme.kt:152) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme$deserialize$$inlined$use$lambda$1.execute(SerializationScheme.kt:206) ~[corda-node-api-2.0.0.jar:?]
at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:61) ~[kryo-4.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme.deserialize(SerializationScheme.kt:205) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$deserialize$1$1.invoke(SerializationScheme.kt:115) ~[corda-node-api-2.0.0.jar:?]
at net.corda.core.serialization.SerializationFactory.withCurrentContext(SerializationAPI.kt:53) ~[corda-core-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:115) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:95) ~[corda-node-api-2.0.0.jar:?]
at net.corda.core.serialization.SerializationFactory.asCurrent(SerializationAPI.kt:67) ~[corda-core-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl.deserialize(SerializationScheme.kt:115) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.RPCApi$ServerToClient$Companion.fromClientMessage(RPCApi.kt:234) ~[corda-node-api-2.0.0.jar:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler.artemisMessageHandler(RPCClientProxyHandler.kt:242) ~[corda-rpc-2.0.0.jar:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler.access$artemisMessageHandler(RPCClientProxyHandler.kt:65) ~[corda-rpc-2.0.0.jar:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler$start$3.invoke(RPCClientProxyHandler.kt:192) ~[corda-rpc-2.0.0.jar:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler$start$3.invoke(RPCClientProxyHandler.kt:65) ~[corda-rpc-2.0.0.jar:?]
at net.corda.client.rpc.internal.RPCClientProxyHandlerKt$sam$MessageHandler$cbde6789.onMessage(RPCClientProxyHandler.kt) ~[corda-rpc-2.0.0.jar:?]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:997) ~[artemis-core-client-2.1.0.jar:2.1.0]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:49) ~[artemis-core-client-2.1.0.jar:2.1.0]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1120) [artemis-core-client-2.1.0.jar:2.1.0]
at org.apache.activemq.artemis.utils.OrderedExecutorFactory$OrderedExecutor$ExecutorTask.run(OrderedExecutorFactory.java:101) [artemis-commons-2.1.0.jar:2.1.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
Caused by: java.lang.IllegalArgumentException: Privacy salt should be 32 bytes.
at net.corda.core.contracts.PrivacySalt.<init>(Structures.kt:272) ~[corda-core-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.DefaultKryoCustomizer$PrivacySaltSerializer.read(DefaultKryoCustomizer.kt:188) ~[corda-node-api-2.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.DefaultKryoCustomizer$PrivacySaltSerializer.read(DefaultKryoCustomizer.kt:182) ~[corda-node-api-2.0.0.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) ~[kryo-4.0.0.jar:?]
... 34 more
Below is my RPConnector:
private CordaRPCOps rpcOps;
@PostConstruct
private void init() {
System.out.println("RPConnector [host=" + host + ", username=" + username + ", password=" + password
+ ", rpcPort=" + rpcPort + "]");
NetworkHostAndPort rpcAddress = new NetworkHostAndPort(host, Integer.valueOf(rpcPort));
CordaRPCClient rpcClient = new CordaRPCClient(rpcAddress);
CordaRPCConnection rpcConnection = rpcClient.start(username, password);
rpcOps = rpcConnection.getProxy();
}
public CordaRPCOps getRPCops() {
return rpcOps;
}
The connection happens successfully but when I try to use RPC connector I get the following error: Below is my controller. When I try to get all nodes I get the error:
@Autowired
private RPConnector rpcOps;
private final List<String> serviceNames = ImmutableList.of("Controller", "Network Map Service");
@GetMapping("/allnodes")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, List<CordaX500Name>> getAllNodes() {
List<NodeInfo> nodeInfoSnapshot = rpcOps.getRPCops().networkMapSnapshot();
return ImmutableMap.of("allnodes",
nodeInfoSnapshot.stream().map(node -> node.getLegalIdentities().get(0).getName()).filter(
name -> !name.equals(rpcOps.getRPCops().nodeInfo().getLegalIdentities().get(0).getName())
&& !serviceNames.contains(name.getOrganisation()))
.collect(toList()));
}
Thank you.
Update on Error, There is a null pointer exception:
java.lang.NullPointerException
at net.corda.core.serialization.SerializedBytes.getHash(SerializationAPI.kt)
at net.corda.core.serialization.SerializedBytes.<init>(SerializationAPI.kt:201)
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme$serialize$1$1.invoke(SerializationScheme.kt:233)
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme$serialize$1$1.invoke(SerializationScheme.kt:152)
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme.withContext(SerializationScheme.kt:191)
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme.access$withContext(SerializationScheme.kt:152)
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme$serialize$1.execute(SerializationScheme.kt:221)
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme$serialize$1.execute(SerializationScheme.kt:152)
at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:61)
at net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme.serialize(SerializationScheme.kt:220)
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1$1.invoke(SerializationScheme.kt:119)
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1$1.invoke(SerializationScheme.kt:95)
at net.corda.core.serialization.SerializationFactory.withCurrentContext(SerializationAPI.kt:53)
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1.invoke(SerializationScheme.kt:119)
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1.invoke(SerializationScheme.kt:95)
at net.corda.core.serialization.SerializationFactory.asCurrent(SerializationAPI.kt:67)
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl.serialize(SerializationScheme.kt:119)
at net.corda.core.serialization.SerializationAPIKt.serialize(SerializationAPI.kt:191)
at net.corda.core.serialization.SerializationAPIKt.serialize$default(SerializationAPI.kt:190)
at net.corda.nodeapi.RPCApi$ClientToServer$RpcRequest.writeToClientMessage(RPCApi.kt:113)
at net.corda.client.rpc.internal.RPCClientProxyHandler.invoke(RPCClientProxyHandler.kt:215)
at com.sun.proxy.$Proxy22.networkMapSnapshot(Unknown Source)