为了账号安全,请及时绑定邮箱和手机立即绑定

java.io.NotSerializableException:

java.io.NotSerializableException:

ITMISS 2021-06-01 15:09:59
尝试从 Corda V1 迁移到 V3。它在 V1 中运行良好,但在使用 Corda V3 后,它抛出以下错误 -java.util.concurrent.ExecutionException: java.io.NotSerializableException: net.corda.core.contracts.TransactionState -> data(net.corda.core.contracts.ContractState) -> 为参数qualifiedCurrency 定义的setter 采用接口java 类型的参数.util.List 但底层类型是 java.util.List -> class com.xxx.agreementnegotiation.state.AgreementNegotiationState在 java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357) atjava.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895) 在 net.corda.core.internal.concurrent.CordaFutureImpl.get(CordaFutureImpl.get(CordaFutureImpl. kt) at com.xxx.agreementnegotiation.api.AgreementNegotiationApi.startInitFlow(AgreementNegotiationApi.java:95) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. sun.java:622) .reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory. java:81) 在 org.glassfish.jersey.server.model.internal。AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) at org.glassfish.jersey.server.model.internal.JavakervoResourceMethodInc .doDispatch(JavaResourceMethodDispatcherProvider.java:160) 在 
查看完整描述

2 回答

?
蓝山帝景

TA贡献1843条经验 获得超7个赞

这是 Corda 3 中的一个错误。它将在 Corda 4 中修复。


同时,解决方法是更改eligibleCurrency为 a List<?>,并根据需要投射其元素:


private List<?> eligibleCurrency;


public List<?> getEligibleCurrency() {

    return eligibleCurrency;

}


public void setEligibleCurrency(List<?> eligibleCurrency) {

    this.eligibleCurrency = eligibleCurrency;

}


查看完整回答
反对 回复 2021-06-02
?
12345678_0001

TA贡献1802条经验 获得超5个赞

根据corda V3,集合是不可变的,因此您不能添加到现有集合中。解决方案是创建一个函数,该函数获取现有集合的副本并将项目添加到其中,最后将其引用到合格货币列表中。


private Collection<SupportingDocument> supportingDocs;

public void addSupportingDoc(SupportingDocument supportingDoc) {


    //since corda 3.1 has unmodifiable collection

    List<SupportingDocument> suppDoc = new ArrayList<SupportingDocument>();

    for(SupportingDocument existingDoc : supportingDocs){

        suppDoc.add(existingDoc);

    }

    // adding new document

    suppDoc.add(supportingDoc);

    this.supportingDocs = Collections.unmodifiableCollection(suppDoc);

}

我希望,这是有道理的



查看完整回答
反对 回复 2021-06-02
  • 2 回答
  • 0 关注
  • 161 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信