运行 流时出现“上下文中无事务”错误

`No transaction in context` error when running a flow

当 运行 Corda 流时,我收到以下错误:

java.lang.IllegalStateException: No transaction in context

我该如何解决这个问题?

此问题可能是由于无法使用 @Suspendable 批注来批注从流中调用的函数造成的。这可以是 FlowLogic.call,也可以是从 FlowLogic.call 中调用的函数(例如 SignTransactionFlow.checkTransaction,如果您在调用 CollectSignaturesFlow 时覆盖此函数)。

如果您 运行 使用以下命令行标志进行流测试:

-Dco.paralleluniverse.fibers.verifyInstrumentation=true

然后如果缺少的注释导致错误,将突出显示。但是,这会减慢测试的 运行 速度。