How to debug chaincode LedgerError - ResourceNotFound

0 votes

I got this I believe pretty common error "..LedgerError - ResourceNotFound: ledger: resource not found" .

To make it simple, this is what I have:

  1. Try simple chaincode, the given chaincode_example02.go codes

  2. turned off security hence no CA (CORE_SECURITY_ENABLED=false CORE_SECURITY_PRIVACY=falss)

  3. 1 peer node only (using 0.5 version), it is a peer docker image

  4. run in dev mode

This is how I deployed the code in dev mode, pls do verify if the cli is correct:

CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./chaincode_example02 

and it shows

'Received REGISTERED, ready for invocations'

Now trying to query it, pls do verify if this cli is correct :

peer chaincode query -n mycc -c '{"Function": "query", "Args": ["b"]}'

but the error returned were :

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

Any idea? I checked all logs under /var but didn't find anything useful, also checked /var/hyperledger and did see some updates under /var/hyperledger/production/db.

This trial seems pretty straight forwards but surprise to get an error.

.. so how should I go about debugging this?

Aug 3, 2018 in Blockchain by aryya
• 7,460 points
1,356 views

1 answer to this question.

0 votes

The following command,

CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./chaincode_example02 

doesn't deploy the chaincode, it simply start and register the chaincode with the validating peer.

Once it is registered, you need todeploy and then invoke it before you can query.

As described here,

First, send a chaincode deploy transaction, only once, to the validating peer. The CLI connects to the validating peer using the properties defined in the core.yaml file. Note: The deploy transaction typically requires a path parameter to locate, build, and deploy the chaincode. However, because these instructions are specific to local development mode and the chaincode is deployed manually, the name parameter is used instead.

peer chaincode deploy -n mycc -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

Once it is deployed, you can invoke it as many times you want and then query the invoked transaction,

To invoke,

peer chaincode invoke -l golang -n mycc -c '{"Function": "invoke", "Args": ["a", "b", "10"]}'

and to query,

peer chaincode query -l golang -n mycc -c '{"Function": "query", "Args": ["b"]}'

Also make sure that you have peer running in one terminal, running the chaincode in 2nd terminal, while deploying, invoking and querying transactions from the third one.

answered Aug 3, 2018 by charlie_brown
• 7,720 points

Related Questions In Blockchain

0 votes
1 answer

How to read a state after writing it into a chaincode?

Data that is 'written' in chaincode is ...READ MORE

answered May 28, 2018 in Blockchain by Perry
• 17,100 points
2,039 views
+1 vote
2 answers

How to return value from a chaincode in Hyperledger Fabric?

Hyperledger Fabric supports only 2 types of ...READ MORE

answered Jun 13, 2018 in Blockchain by Perry
• 17,100 points
2,945 views
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,445 views
0 votes
1 answer

How to use a chaincode that's not on github?

There are two options: If you are not ...READ MORE

answered Aug 3, 2018 in Blockchain by charlie_brown
• 7,720 points
846 views
0 votes
1 answer

How to store picture(s) in a hyperledger blockchain channel

You can hold images as encrypted characters ...READ MORE

answered Jun 16, 2018 in Blockchain by charlie_brown
• 7,720 points
1,345 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP