本文介绍了Hyperledger Fabric Java Chaincode错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用对等链代码部署来运行go src示例,我得到了正确的结果,然后我尝试了Java src示例,在此处输入图像描述

i used peer chaincode deploy to run go src example, i got the right result,then i tried the java src example, enter image description here

我得到了一个链码,但是当我使用该链码进行查询时,它向我显示:

i got a chaincode,but when i used this chaincode for query,it showed me:

Error: Error querying chaincode: rpc error: code = 2 desc = "Error:Failed to launch chaincode spec(Could not get deployment transaction
a3a350ff98660bcade4570acd507d0b380f374ea9399194b39e0301135849feb0732 - LedgerError - ResourceNotFound: ledger: resource not found)"

我使用docker-tool框为超级账本架构创建环境.

i use docker-tool box to create the envirement for hyperledger fabric.

推荐答案

Chaincode ID作为哈希码生成,用于多个参数(链码+参数+源代码的路径)如果您在"deploy"命令的响应中看到类似以下内容的话:

Chaincode ID is generated as hash code for multiple parameters (path to chaincode + arguments + source code )if you see in the response for "deploy" command something like this:

{"jsonrpc":"2.0","result":{"status":"OK","message":"8d803651564981858842409c6a5c3bf3f6ea69f90a6a7bfb672c2c8c3b6eb4c48105c5807e52f1a5ffdce0e86966688019a6c4013ffca524d5896e0b9ae201c6"}

这意味着您的部署事务请求已被接受.从这一刻起,Fabric将尝试为您的链码创建一个容器,并在docker中启动它.如果出现问题并且容器没有启动,您将收到以下响应:

It means that your request to deploy transaction is accepted. From this moment Fabric will try to create a container for your chaincode and start it in docker. In case something goes wrong and the container is not started, you will receive the following response:

"LedgerError - ResourceNotFound: ledger: resource not found" for all your commands.

在您的示例中,您尝试将Java chaincode部署在GO容器中,结果响应为:

In your example you are trying to deploy Java chaincode in a GO container and as a result the response is:

(INFO 002 Deploy result: type GOLANG chaincodeID:...)

之所以发生这种情况,是因为Fabric不使用语言"变量来检测平台类型(对于 2016年9月9日可用的版本有效)

That is happening because Fabric does not use a "language" variable to detect platform type (valid for version which was available 09/09/2016)

我设法使用以下REST请求部署了Java链码:

I managed to deploy a Java chaincode using the following REST request:

curl -XPOST -d ‘{"jsonrpc": "2.0", "method": "deploy", "params": {"type": 4,"chaincodeID": {"path": "/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/java/SimpleSample","language": "java"}, "ctorMsg": { "args": ["init", "a", "100", "b", "1000"] }},"id": 0}' http://localhost:7050/chaincode

type:4表示此链码是Java,应使用适当的容器. (对于GO,我们应该使用type:1)

type:4 means that this chaincode is Java and appropriate container should be used. (for GO we should use type:1)

请记住,Java当前仅适用于security.enabled=falsesecurity.enabled=true,您将看到以下错误消息:

Keep in mind that Java currently works with security.enabled=false only and with security.enabled=true you will see the following error message:

[dockercontroller] deployImage -> ERRO 095 Error building images: API error (500): {"message":"The Dockerfile (Dockerfile) cannot be empty"}

这篇关于Hyperledger Fabric Java Chaincode错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:54