简体   繁体   中英

hyperledger fabric java chaincode error

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)"

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

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"}

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. 

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:...)

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

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 means that this chaincode is Java and appropriate container should be used. (for GO we should use type:1 )

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"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM