You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I call a submit method from application via gateway, I received an Exception below.
Caused by: org.hyperledger.fabric.client.EndorseException: io.grpc.StatusRuntimeException: ABORTED: failed to collect enough transaction endorsements, see attached details for more info
at org.hyperledger.fabric.client.GatewayClient.endorse(GatewayClient.java:74)
at org.hyperledger.fabric.client.ProposalImpl.endorse(ProposalImpl.java:76)
at org.hyperledger.fabric.client.Proposal.endorse(Proposal.java:64)
at pers.u8f23.fabric.app.api.AbstractAssetContractSubmit.createAsset(AbstractAssetContractSubmit.java:13)
at pers.u8f23.fabric.app.Main.chaincodeOperations(Main.java:84)
at pers.u8f23.fabric.app.Main.main(Main.java:65)
Caused by: io.grpc.StatusRuntimeException: ABORTED: failed to collect enough transaction endorsements, see attached details for more info
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:268)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:249)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:167)
at org.hyperledger.fabric.protos.gateway.GatewayGrpc$GatewayBlockingStub.endorse(GatewayGrpc.java:455)
at org.hyperledger.fabric.client.GatewayClient.endorse(GatewayClient.java:72)
... 5 more
Detail message attached to this Exception is ProposalResponsePayloads do not match.
Returned type is a generic class. Both the generic type and the type argument are defined as type in fabric demo .
// at this point we can assert that the value is// representing a complex data type// so we can get this from// the type registry, and get the list of propertyNames// it should havefinalDataTypeDefinitiondtd = this.typeRegistry.getDataType(ts);
finalSet<String> keySet = dtd.getProperties().keySet();
finalString[] propNames = keySet.toArray(newString[keySet.size()]);
// Note: whilst the current JSON library does pretty much// everything is required, this part is hard.// we want to create a JSON Object based on the value,// with certain property names.// Based on the constructors available we need to have a two// step process, create a JSON Object, then create the object// we really want based on the propNamesfinalJSONObjectobj = newJSONObject(newJSONObject(value), propNames);
buffer = obj.toString().getBytes(UTF_8);
Those codes seem to be used to serializer complex objects returned by chaincode methods. The given value is processed by org.json.JSONObject, which using java.util.HashMap to obtain key-value pairs and is not sure to make pairs ordered by fixed sequence. I suspect this is a bug.
8f235831
changed the title
Can methods in contract return generic types?
May org.json.JSONObject used in org.hyperledger.fabric.contract.execution.JSONTransactionSerializer lead submit payloads not matching?
Nov 14, 2024
I have had a quick look through the implementation and I suspect that you are correct about the built-in JSON serializer not ensuring consistent field ordering in JSON objects. Both the JSON org.json serializer and the fabric-chaincode-shim TypeSchema use unordered maps to store fields.
As a workaround, I would suggest using an alternative serialization solution, such as Jackson with its @JsonPropertyOrder annotation. You could either do the serialization of transaction function return values explicitly in your smart contract code, and declare the transaction function as returning a String, or provide your own serializer implementation that does the same.
When I call a submit method from application via gateway, I received an Exception below.
Detail message attached to this Exception is
ProposalResponsePayloads do not match
.Returned type is a generic class. Both the generic type and the type argument are defined as type in fabric demo .
Does this chaincode api support java generic type as method return type?
Anyone is welcome to answer this question.
The text was updated successfully, but these errors were encountered: