Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
226 views
in Technique[技术] by (71.8m points)

Corda V3 Error java.util.concurrent.ExecutionException

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:-

[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

It occurs in the following sources.

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;
    }

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...