我正在尝试从 fabric-samples 安装 facar 的 java 链代码,但出现错误。
https://github.com/hyperledger/fabric-samples/tree/release-1.4/chaincode/fabcar/java
在链码的实例化过程中,我正在尝试并得到错误
有人可以帮助我吗,非常感谢并提前感谢。
我正在使用基本网络文件夹和下面的脚本来创建和安装网络,实例化和调用链代码。
#!/bin/bash
#
# Copyright IBM Corp All Rights Reserved
#
# SPDX-License-Identifier: Apache-2.0
#
# Exit on first error, print all commands.
set -ev
# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1
docker-compose -f docker-compose.yml down
docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb
docker ps -a
# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
export FABRIC_START_TIMEOUT=10
#echo ${FABRIC_START_TIMEOUT}
sleep ${FABRIC_START_TIMEOUT}
# Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block
docker-compose -f docker-compose.yml up -d cli
sleep 5
#install chaincode
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode install -n mycc -v 1.0 -p /opt/gopath/src/github.com/fabcar/java -l java
#instantiate chaincode
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -l java -v 1.0 -c '{"Args":[""]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
sleep 5
#invoke chaincode
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_ADDRESS=peer0.org1.example.com:7051" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc -c '{"function":"initLedger","Args":[""]}'
下面给出的 docker logs peer0.org1.example.com 命令的输出
2019-08-06 09:54:26.150 UTC [endorser] SimulateProposal -> ERRO 043 [mychannel][e0746cf6] 未能调用链代码名称:“lscc”,错误:交易返回失败:调用未定义的合约方法
下面给出的 docker logs dev-peer0.org1.example.com-mycc-1.0 命令的输出
09:54:26:142 SEVERE org.hyperledger.fabric.Logger error Undefined contract method
调用 org.hyperledger.fabric.shim.ChaincodeException:在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect 的 org.hyperledger.fabric.contract.ContractInterface.unknownTransaction(ContractInterface.java:76) 调用未定义的合约方法。 NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.hyperledger.fabric.contract .execution.impl.ContractExecutionService.executeRequest(ContractExecutionService.java:57) 在 org.hyperledger.fabric.contract.ContractRouter.processRequest(ContractRouter.java:87) 在 org.hyperledger.fabric.contract.ContractRouter。init(ContractRouter.java:103) 在 org.hyperledger.fabric.shim.impl.Handler.lambda$handleInit$0(Handler.java:280) 在 java.lang.Thread.run(Thread.java:748)
:54:26:147 SEVERE org.hyperledger.fabric.shim.impl.Handler lambda$handleInit$0 [e0746cf6] Init failed.
发送错误