hyperledger / fabric-samples

Samples for Hyperledger Fabric
https://wiki.hyperledger.org/display/fabric
Apache License 2.0
2.74k stars 3.34k forks source link

application-gateway-java not working #747

Open sgroh opened 2 years ago

sgroh commented 2 years ago

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?

b-malina commented 2 years ago

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

gqqnbig commented 9 months ago

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.