Corda V3错误java.util.concurrent.ExecutionException [英] Corda V3 Error java.util.concurrent.ExecutionException

查看:60
本文介绍了Corda V3错误java.util.concurrent.ExecutionException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天从Corda V2升级到了Corda V3.在V2上运行的程序无法正常工作,请帮助我.发生以下错误:-

I upgraded today from Corda V2 to Corda V3. Programs that were running on V2 will not work so please help me. The following error occurs:-

[错误] 16:02:31,129 [qtp1715876585-27](ExampleApi.java:226)api.ExampleApi.myMethod-java.io.NotSerializableException:net.corda.core.contracts.TransactionState->data(net.corda.core.contracts.ContractState)->构造函数参数-"parameter_2"-未引用"com.example.state.MyState类"的属性-> com.example.state.MyState类{}java.util.concurrent.ExecutionException:java.io.NotSerializableException:net.corda.core.contracts.TransactionState->data(net.corda.core.contracts.ContractState)->构造函数参数-"parameter_2"-未引用"com.example.state.MyState类"的属性-> com.example.state.MyState类

[ERROR] 16:02:31,129 [qtp1715876585-27] (ExampleApi.java:226) api.ExampleApi.myMethod - java.io.NotSerializableException: net.corda.core.contracts.TransactionState -> data(net.corda.core.contracts.ContractState) -> Constructor parameter - "parameter_2" - doesn't refer to a property of "class com.example.state.MyState" -> class com.example.state.MyState {} java.util.concurrent.ExecutionException: java.io.NotSerializableException: net.corda.core.contracts.TransactionState -> data(net.corda.core.contracts.ContractState) -> Constructor parameter - "parameter_2" - doesn't refer to a property of "class com.example.state.MyState" -> class com.example.state.MyState

它发生在以下来源.

flowHandle = rpcOps.startTrackedFlowDynamic(Myflow.Initiator.class, 
parameter1 ,parameter_2);
final SignedTransaction result = flowHandle
        .getReturnValue()
        .get();




public class MyState implements QueryableState,LinearState {
    private final Party partyA; 
    private final Party partyB; 
    private final int parameter_2
    private final UniqueIdentifier linearId;

    public Party getPartyA() {
        return partyA;
    }

    public Party getPartyB() {
        return partyB;
    }

    public int getParameter_2() {
        return parameter_2;
    }

    public MyState(Party partyA, Party partyB, int parameter_2) {
        this.partyA = partyA;
        this.partyB = partyB;
        parameter_2 = parameter_2;
        this.linearId = new UniqueIdentifier();
    }


    @Override
    public Iterable<MappedSchema> supportedSchemas() {
        return ImmutableList.of(new MySchemaV1());
    }

    @Override
    public PersistentState generateMappedObject(MappedSchema schema) {
        if (schema instanceof MySchemaV1){
            return new MySchemaV1.PersistentAA(
                    this.pratyA.getName().toString(),
                    this.partyB.getName().toString(),
                    this.parameter_2,
                    this.linearId.getId()
            );
        }else{
            throw new IllegalArgumentException("abnormal argument");
        }
    }

    @Override
    public List<AbstractParty> getParticipants() {
        return Arrays.asList(this.partyA,this.partyB);
    }

    @Override
    public String toString() {
        return  String.format("%s(partyA=%s, partyB=%s, parameter2=%s, linearId=%s)",
                getClass().getSimpleName(),this.partyA,this.partyB,this.parameter_2,this.linearId);
    }

    @NotNull
    @Override
    public UniqueIdentifier getLinearId() {
        return this.linearId;
    }

}

推荐答案

字段名称中的下划线没有限制.例如,以下状态定义有效:

There is no limitation on underscores in field names. For example, the following state definition is valid:

public class IOUState implements ContractState {
    private final Integer value_2;

    public IOUState(Integer value_2) { this.value_2 = value_2; }

    public Integer getValue_2() { return value_2; }

    @Override public List<AbstractParty> getParticipants() {
        return ImmutableList.of();
    }
}

您的代码中的其他地方肯定有问题.

There must be an issue elsewhere in your code.

这篇关于Corda V3错误java.util.concurrent.ExecutionException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆