我有一个使用 Build Your First Network 的 Hyperledger Fabric V1.0 网络设置.
我已经通过运行命令./byfn.sh -m up
建立了网络。
现在,所有Peer、Orderers 和 CA(在 docker-compose-e2e.yaml 中配置)均已启动并运行。
我正在尝试使用 fabric-sdk-java 连接到该网络.
但是当使用以下代码进行用户注册时
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
}
我收到错误
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
我指的是单元测试类End2endIT.java中显示的代码
请有人分享您的知识,以找出我做错的地方。
此外,我不确定它在哪里配置"affiliation":"org1.department1"
。
我需要在 .yaml
文件中添加任何内容吗?
最佳答案
这些是为任何 CA 容器引导的从属关系
> affiliations:
> org1:
> - department1
> - department2
> org2:
> - department1
但是您可以通过该功能根据您的组织添加新的隶属关系
await caClient.newAffiliationService().create({ "name": "AFFILIATION_NAME }, adminObj)
关于java - 使用 Fabric Client Java SDK V1.0.1 进行用户注册时获取隶属关系失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45934704/