gpt4 book ai didi

java - 无法调用链码名称 :"lscc",错误 : transaction returned with failure: Undefined contract method called

转载 作者:行者123 更新时间:2023-12-02 02:01:15 32 4
gpt4 key购买 nike

我正在尝试从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 logpeer0.org1.example.com 命令的输出

2019-08-06 09:54:26.150 UTC [endorser] SimulateProposal -> ERRO 043 [mychannel][e0746cf6] failed to invoke chaincode name:"lscc" , error: transaction returned with failure: Undefined contract method called

Output of docker logs dev-peer0.org1.example.com-mycc-1.0 command given below

09:54:26:142 SEVERE  org.hyperledger.fabric.Logger error                                              Undefined contract method

calledorg.hyperledger.fabric.shim.ChaincodeException: Undefined contract method called at org.hyperledger.fabric.contract.ContractInterface.unknownTransaction(ContractInterface.java:76) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.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) at org.hyperledger.fabric.contract.ContractRouter.processRequest(ContractRouter.java:87) at org.hyperledger.fabric.contract.ContractRouter.init(ContractRouter.java:103) at org.hyperledger.fabric.shim.impl.Handler.lambda$handleInit$0(Handler.java:280) at java.lang.Thread.run(Thread.java:748)

:54:26:147 SEVERE  org.hyperledger.fabric.shim.impl.Handler lambda$handleInit$0                     [e0746cf6] Init failed.

Sending ERROR

最佳答案

也许你已经忘记了@Default装饰器

@Contract(name = "MyContract",
info = @Info(
title = "My Contract",
description = "",
version = "0.0.1"
)
)
@Default
public class MyContract implements ContractInterface {

关于java - 无法调用链码名称 :"lscc",错误 : transaction returned with failure: Undefined contract method called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57373987/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com