0

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

}
3
  • Please can you post the class definition of MyState? Commented Apr 9, 2018 at 17:36
  • Thank you, joel. I added the definition of MyState. Commented Apr 10, 2018 at 0:50
  • Joel, I'm sorry. The definition of MyState was incorrect. The member variable "paramter 2" has an underscore, and "parameter_ 2" was correct. I wrote it in the answer, but this problem was solved by deleting the underscore. I could use underscore in V2, is this a bug? Commented Apr 12, 2018 at 10:55

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Joel I'm sorry. When I tried with the following procedure, no error occurred. 1. Download Cordapp-example of V3 2. Change vaule of IUSUState.java to value_value 3. Confirm by running 4. No error occurred I can not upload the source code which caused the error, but certainly, by erasing the underscore, the error no longer exists. Please investigate a little more and let me ask you a question if you get useful information. Thank you.
1

You do not seem to be able to use underscores for the member variables of State in Corda V3.

In the sample code above, when we changed "parameter 2" to "parameter 2", Exception ceased to appear.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.