fabric-samples icon indicating copy to clipboard operation
fabric-samples copied to clipboard

application-gateway-java not working

Open sgroh opened this issue 3 years ago • 2 comments

Following the basic instruction from https://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html And using the java chaincode: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-java/ -ccl java

The asset-transfer-basic/application-gateway-java application fails endorsing the transaction with this error:

org.hyperledger.fabric.client.EndorseException: io.grpc.StatusRuntimeException: ABORTED: failed to endorse transaction, see attached details for more info
    at org.hyperledger.fabric.client.GatewayClient.endorse (GatewayClient.java:57)
    at org.hyperledger.fabric.client.ProposalImpl.endorse (ProposalImpl.java:71)
    at org.hyperledger.fabric.client.ContractImpl.submitTransaction (ContractImpl.java:38)
    at App.initLedger (App.java:150)
    at App.run (App.java:124)
    at App.main (App.java:81)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:830)
Caused by: io.grpc.StatusRuntimeException: ABORTED: failed to endorse transaction, see attached details for more info
    at io.grpc.stub.ClientCalls.toStatusRuntimeException (ClientCalls.java:262)
    at io.grpc.stub.ClientCalls.getUnchecked (ClientCalls.java:243)
    at io.grpc.stub.ClientCalls.blockingUnaryCall (ClientCalls.java:156)
    at org.hyperledger.fabric.protos.gateway.GatewayGrpc$GatewayBlockingStub.endorse (GatewayGrpc.java:472)
    at org.hyperledger.fabric.client.GatewayClient.endorse (GatewayClient.java:55)
    at org.hyperledger.fabric.client.ProposalImpl.endorse (ProposalImpl.java:71)
    at org.hyperledger.fabric.client.ContractImpl.submitTransaction (ContractImpl.java:38)
    at App.initLedger (App.java:150)
    at App.run (App.java:124)
    at App.main (App.java:81)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:830)

Thoughts?

sgroh avatar May 18 '22 19:05 sgroh

for me it worked after changing the name of the function called (InitLedger). Check if you are using lower/upper camel case consistently w.r.t. the method names in the contract

b-malina avatar Jun 13 '22 17:06 b-malina

Check if you can invoke the contract from command line, ie.

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}'

from https://hyperledger-fabric.readthedocs.io/en/release-2.5/test_network.html

If the peer command also throws errors, then you debug from there.

gqqnbig avatar Sep 23 '23 08:09 gqqnbig