猿问

java.io.NotSerializableException:

尝试从 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) 在 

ITMISS
浏览 162回答 2
2回答

蓝山帝景

这是 Corda 3 中的一个错误。它将在 Corda 4 中修复。同时,解决方法是更改eligibleCurrency为 a List<?>,并根据需要投射其元素:private List<?> eligibleCurrency;public List<?> getEligibleCurrency() {&nbsp; &nbsp; return eligibleCurrency;}public void setEligibleCurrency(List<?> eligibleCurrency) {&nbsp; &nbsp; this.eligibleCurrency = eligibleCurrency;}

12345678_0001

根据corda V3,集合是不可变的,因此您不能添加到现有集合中。解决方案是创建一个函数,该函数获取现有集合的副本并将项目添加到其中,最后将其引用到合格货币列表中。private Collection<SupportingDocument> supportingDocs;public void addSupportingDoc(SupportingDocument supportingDoc) {&nbsp; &nbsp; //since corda 3.1 has unmodifiable collection&nbsp; &nbsp; List<SupportingDocument> suppDoc = new ArrayList<SupportingDocument>();&nbsp; &nbsp; for(SupportingDocument existingDoc : supportingDocs){&nbsp; &nbsp; &nbsp; &nbsp; suppDoc.add(existingDoc);&nbsp; &nbsp; }&nbsp; &nbsp; // adding new document&nbsp; &nbsp; suppDoc.add(supportingDoc);&nbsp; &nbsp; this.supportingDocs = Collections.unmodifiableCollection(suppDoc);}我希望,这是有道理的
随时随地看视频慕课网APP

相关分类

Java
我要回答