我收到以下错误:
步骤1: serviceHub.jdbcSession()。prepareStatement(“ Query”)
步骤2: 我已经执行了step1。
步骤3: 我正在获取所需的数据。
但是我也遇到了以下异常。
com.esotericsoftware.kryo.KryoException: java.lang.UnsupportedOperationException: com.zaxxer.hikari.pool.HikariProxyPreparedStatement, which is a closeable resource, has been detected during flow checkpointing. Restoring such resources across node restarts is not supported. Make sure code accessing it is confined to a private method or the reference is nulled out.
Serialization trace:
dataObject (co.paralleluniverse.fibers.Stack)
stack (net.corda.node.services.statemachine.FlowStateMachineImpl)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:101) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:66) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObjectOrNull(Kryo.java:629) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:87) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:505) ~[kryo-4.0.0.jar:?]
at co.paralleluniverse.fibers.Fiber$FiberSerializer.write(Fiber.java:2090) ~[quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.Fiber$FiberSerializer.write(Fiber.java:2067) ~[quasar-core-0.7.9-jdk8.jar:0.7.9]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.0.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeClassAndObject(ReplaceableObjectKryo.java:54) ~[quasar-core-0.7.9-jdk8.jar:0.7.9]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme$serialize$1$1.invoke(KryoSerializationScheme.kt:116) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme$serialize$1$1.invoke(KryoSerializationScheme.kt:37) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme.withContext(KryoSerializationScheme.kt:80) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme.access$withContext(KryoSerializationScheme.kt:37) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme$serialize$1.execute(KryoSerializationScheme.kt:109) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme$serialize$1.execute(KryoSerializationScheme.kt:37) ~[corda-node-api-3.3-corda.jar:?]
at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:61) ~[kryo-4.0.0.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme.serialize(KryoSerializationScheme.kt:108) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1$1.invoke(SerializationScheme.kt:126) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1$1.invoke(SerializationScheme.kt:86) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.core.serialization.SerializationFactory.withCurrentContext(SerializationAPI.kt:66) ~[corda-core-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1.invoke(SerializationScheme.kt:126) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl$serialize$1.invoke(SerializationScheme.kt:86) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.core.serialization.SerializationFactory.asCurrent(SerializationAPI.kt:80) ~[corda-core-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.SerializationFactoryImpl.serialize(SerializationScheme.kt:126) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.core.serialization.SerializationAPIKt.serialize(SerializationAPI.kt:231) ~[corda-core-3.3-corda.jar:?]
at net.corda.core.serialization.SerializationAPIKt.serialize$default(SerializationAPI.kt:230) ~[corda-core-3.3-corda.jar:?]
at net.corda.node.services.statemachine.StateMachineManagerImpl.serializeFiber(StateMachineManagerImpl.kt:408) ~[corda-node-3.3-corda.jar:?]
at net.corda.node.services.statemachine.StateMachineManagerImpl.updateCheckpoint(StateMachineManagerImpl.kt:540) ~[corda-node-3.3-corda.jar:?]
at net.corda.node.services.statemachine.StateMachineManagerImpl.access$updateCheckpoint(StateMachineManagerImpl.kt:63) ~[corda-node-3.3-corda.jar:?]
at net.corda.node.services.statemachine.StateMachineManagerImpl$initFiber$2.invoke(StateMachineManagerImpl.kt:440) ~[corda-node-3.3-corda.jar:?]
at net.corda.node.services.statemachine.StateMachineManagerImpl$initFiber$2.invoke(StateMachineManagerImpl.kt:63) ~[corda-node-3.3-corda.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl$suspend$2.write(FlowStateMachineImpl.kt:520) ~[corda-node-3.3-corda.jar:?]
at co.paralleluniverse.fibers.Fiber$3.run(Fiber.java:1994) ~[quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:824) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_201]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:62) [corda-node-3.3-corda.jar:?]
Caused by: java.lang.UnsupportedOperationException: com.zaxxer.hikari.pool.HikariProxyPreparedStatement, which is a closeable resource, has been detected during flow checkpointing. Restoring such resources across node restarts is not supported. Make sure code accessing it is confined to a private method or the reference is nulled out.
at net.corda.nodeapi.internal.serialization.kryo.AutoCloseableSerialisationDetector.write(KryoSerializationScheme.kt:31) ~[corda-node-api-3.3-corda.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AutoCloseableSerialisationDetector.write(KryoSerializationScheme.kt:26) ~[corda-node-api-3.3-corda.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.0.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeClassAndObject(ReplaceableObjectKryo.java:54) ~[quasar-core-0.7.9-jdk8.jar:0.7.9]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:362) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:303) ~[kryo-4.0.0.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.0.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.9-jdk8.jar:0.7.9]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-4.0.0.jar:?]
... 42 more
我正在尝试使用jdbc连接从Corda流中的数据库中获取数据。从数据库中获取数据时,出现上述异常。
答案 0 :(得分:1)
将jdbc
代码放入未用@Suspendable
注释的函数中。理想情况下,您应该将此代码放在@CordaService
中,以将其与其余流代码(https://lankydan.dev/2018/08/19/corda-services-101)隔离开。
Corda 检查点在挂起时会序列化当前堆栈(例如,调用sendAndReceive
)。如错误所示,由于jdbc连接是可关闭的,因此无法对其进行序列化。
仅对带有@Suspendable
注释的方法进行检查。更正确地说,必须用@Suspendable
注释暂停的方法。