'Error: endorsement failure during invoke. response: status:500 message:"error in simulation:

I'm using hyperledger fabric 2.0. I have two orgs. ORGA and ORGB. I'm using "test-network" of fabric-samples repository as my network. I have edited javascript version of fabcar chaincode by changing the variable names in the init functions and other functions of fabcar.js chaincode. I have installed my edited chaincode on the peers of two orgs. I have also successfully approved chaincode on 2 orgs. Successfully committed chaincode definition to the channel. But when I'm trying to invoke chaincode using command with function initLedger I'm getting error:

Command:

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n deed --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 --isInit -c '{"function":"initLedger","Args":[]}' 

I'm getting an error shown below:

Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 5b14718ab2408cd29dafc9daf33e193534c7a1262afebd0ca5eae3b0116aeca0: could not launch chaincode deed_1:48b197c4e734f589019d61ba1615ad9fc2b0007f478ab92a8b34714bc3c404e0: chaincode registration failed: container exited with 1"

help me. Regards, Satish



Solution 1:[1]

The error is telling you that the container hosting the chaincode has exited after the chaincode process terminated with an exit code of 1. If you've configured the peer to stream the chaincode container logs (vm.docker.attachStdout=true / CORE_VM_DOCKER_ATTACHSTDOUT=true), you can look at the peer logs to see any errors produced by the chaincode.

Solution 2:[2]

Check your chaincode, their is some typo in your code. check --> repair --> run following script -->

./startFabric.sh javascript

Solution 3:[3]

Fabric provides monitordocker.sh along with its commercial-paper sample in the Fabric sample (https://hyperledger-fabric.readthedocs.io/en/latest/deploy_chaincode.html#setup-logspout-optional)

Run the below line in a separate PUTTY window to keep monitoring the logs across all containers in docker. Note that "fabric_test" is the name of the network that needs to be monitored.

./monitordocker.sh fabric_test

Now run the fabric command that results in error and you should see details on the log in the other PUTTY window.

Solution 4:[4]

The name of the invoked chaincode does not match the name of the committed one. Check it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 southwick
Solution 2 Mohit Rakhade
Solution 3 Karthik
Solution 4 Alex Kojin