Corda V3错误java.util.concurrent.ExecutionException
我今天从Corda V2升级到Corda V3。 在V2上运行的程序将无法运行,请帮助我。 发生以下错误:- [错误]16:02:31129[qtp1715876585-27](示例api.java:226) api.ExampleApi.myMethod-java.io.NotSerializableException: net.corda.core.contracts.TransactionState-> 数据(net.corda.core.contracts.ContractState)->构造函数参数 -“参数_2”-未引用“class com.example.state.MyState”->class com.example.state.MyState{}的属性 java.util.concurrent.ExecutionException: java.io.NotSerializableException: net.corda.core.contracts.TransactionState-> 数据(net.corda.core.contracts.ContractState)->构造函数参数 -“参数_2”-未引用“class com.example.state.MyState”->class com.example.state.MyState的属性 它发生在以下来源中Corda V3错误java.util.concurrent.ExecutionException,corda,Corda,我今天从Corda V2升级到Corda V3。 在V2上运行的程序将无法运行,请帮助我。 发生以下错误:- [错误]16:02:31129[qtp1715876585-27](示例api.java:226) api.ExampleApi.myMethod-java.io.NotSerializableException: net.corda.core.contracts.TransactionState-> 数据(net.corda.core.contracts.ContractState)-
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;
}
}
flowHandle=rpcOps.starttracketflowdynamic(Myflow.Initiator.class,
参数1,参数2);
最终签署的交易结果=flowHandle
.getReturnValue()
.get();
公共类MyState实现QueryableState、LinearState{
私人最终党;
私人最后一方b;
私有最终int参数_2
专用最终唯一标识符;
公众党{
返回partyA;
}
公众党{
返回党;
}
public int getParameter_2(){
返回参数_2;
}
公共MyState(Party partyA、Party partyB、int参数_2){
this.partyA=partyA;
this.partyB=partyB;
参数_2=参数_2;
this.linearId=新的唯一标识符();
}
@凌驾
公共Iterable supportedSchemas(){
返回ImmutableList.of(new MySchemaV1());
}
@凌驾
公共PersistentState generateMappedObject(MappedSchema){
if(MySchemaV1的模式实例){
返回新的MySchemaV1.persistenta(
this.pratyA.getName().toString(),
this.partyB.getName().toString(),
这是参数_2,
this.linearId.getId()
);
}否则{
抛出新的IllegalArgumentException(“异常参数”);
}
}
@凌驾
公开名单{
返回Arrays.asList(this.partyA,this.partyB);
}
@凌驾
公共字符串toString(){
返回字符串.format(“%s(partyA=%s,partyB=%s,parameter2=%s,linearId=%s)”,
getClass().getSimpleName(),this.partyA,this.partyB,this.parameter_2,this.linearId);
}
@NotNull
@凌驾
公共唯一标识符getLinearId(){
把这个还给我;
}
}
在Corda V3中,您似乎无法对状态的成员变量使用下划线
在上面的示例代码中,当我们将“parameter 2”更改为“parameter 2”时,异常停止出现。您似乎无法在Corda V3中为状态的成员变量使用下划线
在上面的示例代码中,当我们将“parameter 2”更改为“parameter 2”时,异常停止出现。字段名中的下划线没有限制。例如,以下状态定义有效:
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();
}
}
public类Ioutate实现ContractState{
私有最终整数值_2;
公共值(整数值_2){this.value_2=value_2;}
公共整数getValue_2(){返回值_2;}
@覆盖公共列表getParticipants(){
返回ImmutableList.of();
}
}
代码中的其他地方一定有问题。字段名中的下划线没有限制。例如,以下状态定义有效:
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();
}
}
public类Ioutate实现ContractState{
私有最终整数值_2;
公共值(整数值_2){this.value_2=value_2;}
公共整数getValue_2(){返回值_2;}
@覆盖公共列表getParticipants(){
返回ImmutableList.of();
}
}
代码中的其他地方一定有问题。请发布
MyState
的类定义好吗?谢谢你,joel。我添加了MyState的定义。joel,对不起。MyState的定义不正确。成员变量“parameter 2”有下划线和“parameter_2”“是正确的。我在答案中写了它,但通过删除下划线解决了这个问题。我可以在V2中使用下划线,这是错误吗?请发布MyState
”的类定义。谢谢你,joel。我添加了MyState的定义。joel,很抱歉。MyState的定义不正确。成员变量“parameter 2”有下划线和“参数2”是正确的。我在答案中写的,但是这个问题通过删除下划线得到了解决。我可以在V2中使用下划线,这是错误吗?Joel,很抱歉。当我尝试以下过程时,没有出现错误。1.下载V3 2的Cordapp示例。将IUSUState.java的值更改为值_值3。通过运行4进行确认。我没有出现错误无法上载导致错误的源代码,但可以肯定的是,通过删除下划线,错误不再存在。请进一步调查,如果您得到有用的信息,让我问您一个问题。谢谢。Joel我很抱歉。当我尝试以下过程时,没有发生错误。1.下载V3 2.C的Cordapp示例将IUSUState.java的vaule更改为value_value 3。通过运行4进行确认。未发生错误。我无法上载导致错误的源代码,但当然,通过删除下划线,错误不再存在。请进一步调查,如果您获得有用的信息,请让我问您一个问题。谢谢。