I have a Hyperledger Fabric V1.0 network setup using Build Your First Network.
I have made the network up by running the command ./byfn.sh -m up
.
Now all the Peers, Orderers and CAs(configured in docker-compose-e2e.yaml) are up and running.
And I am trying to connect to this network using fabric-sdk-java.
But when doing user registration using the following code
HFCAClient ca = sampleOrg.getCAClient();
final String orgName = sampleOrg.getName();
final String mspid = sampleOrg.getMSPID();
ca.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
SampleUser admin = sampleStore.getMember("ädmin", orgName);
if (!admin.isEnrolled()) { //Preregistered admin only needs to be enrolled with Fabric caClient.
admin.setEnrollment(ca.enroll(admin.getName(), "adminpw"));
admin.setMspId(mspid);
}
sampleOrg.setAdmin(admin); // The admin of this org --
SampleUser user = sampleStore.getMember("user", sampleOrg.getName());
if (!user.isRegistered()) { // users need to be registered AND enrolled
RegistrationRequest rr = new RegistrationRequest(user.getName(), "org1.department1");
user.setEnrollmentSecret(ca.register(rr, admin// here comes the error
}
I am getting the error
2017-08-29 07:44:01,132 main ERROR HFCAClient:237 - com.test.blockchain.client.test.SampleUser@73846619
org.hyperledger.fabric_ca.sdk.exception.RegistrationException: Error while registering the user com.test.blockchain.client.test.SampleUser@73846619 url: https://192.168.99.100:7054 POST request to https://192.168.99.100:7054/api/v1/register failed request body {"id":"user1","type":"user","max_enrollments":0,"affiliation":"org1.department1","attrs":[]} with status code: 500. Response: {"success":false,"result":null,"errors":[{"code":0,"message":"Failed getting affiliation 'org1.department1': sql: no rows in result set"}],"messages":[]}
at org.hyperledger.fabric_ca.sdk.HFCAClient.register(HFCAClient.java:236)
at com.test.blockchain.client.test.Test.setup(Test.java:164)
at com.test.blockchain.client.test.Test.main(Test.java:982)
Caused by: java.lang.Exception: POST request to https://192.168.99.100:7054/api/v1/register failed request body {"id":"user1","type":"user","max_enrollments":0,"affiliation":"org1.department1","attrs":[]} with status code: 500. Response: {"success":false,"result":null,"errors":[{"code":0,"message":"Failed getting affiliation 'org1.department1': sql: no rows in result set"}],"messages":[]}
at org.hyperledger.fabric_ca.sdk.HFCAClient.httpPost(HFCAClient.java:609)
at org.hyperledger.fabric_ca.sdk.HFCAClient.register(HFCAClient.java:227)
... 2 more
I am referring the codes shown in the unit test class End2endIT.java
Someone please share your knowledge to find out where I am doing wrong.
Also I am not sure where it is configuring "affiliation":"org1.department1"
.
Do I need to add anything in my .yaml
file?
You configure the affiliation when you create the crypto material. In your case when you generate the
./byfn.sh -m up
command. You have created your keys (your certificates) when you executed the ./byfn.sh -m up, so you don't need to call the CA to register any user.Also, your error code is the 500, so the cause of your error should be other. Could you try to invoke the chaincode?
Have you changed something in the crypto-config.yaml file? And in the docker-compose-e2e.yaml file?