Fabric调用链码报错
Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction aaeb7054ce35680547c88d4f166767ef5cd367e09358135bb821e permission_1.0.1:a678e6451f0636edc070cc702ccdec1da6370774f3d40bb6f67498f1cb2b6726: error starting container: error starting container: API error (400): failed to create shim teate failed: unable to start container process: exec: \"chaincode\": executable file not found in $PATH: unknown"
error starting container: API error (400): failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "chaincode": executable file not found in $PATH: unknown
检查方法
1. 查看链码容器状态【status】
docker ps -a
这里可以看到,链码容器的状态是Create,说明链码容器并未成功启动。
2. 查看链码是否安装成功
#前提:设置环境变量
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID=Org1MSP
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/creator1@org1.example.com/msp
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_ADDRESS=localhost:7051
export TARGET_TLS_OPTIONS=(-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" --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")
#查看节点已安装列表
peer chaincode list --installed --channelID mychannel
这里可以看到,输出的列表为空,说明没有链码被安装,所以调用链码时会报错
解决方法
1.重新安装链码,安装链码时注意检查是否有报错,是否成功安装
2.显示安装成功,但是仍然出现上方问题?
检查智能合约文件的package是否为main包,是否写了主程序入口函数