Gir*_*007 3 java blockchain hyperledger hyperledger-fabric
我有一个使用Build Your First Network的Hyperledger Fabric V1.0 网络设置。
我通过运行命令建立了网络./byfn.sh -m up。现在所有Peers、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
}
Run Code Online (Sandbox Code Playgroud)
我收到错误
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
Run Code Online (Sandbox Code Playgroud)
我指的是单元测试类End2endIT.java 中显示的代码
有人请分享您的知识,以找出我做错的地方。
另外我不确定它在哪里配置"affiliation":"org1.department1".
我需要在我的.yaml文件中添加任何内容吗?
小智 5
这些是为任何 CA 容器引导的从属关系
> affiliations:
> org1:
> - department1
> - department2
> org2:
> - department1
Run Code Online (Sandbox Code Playgroud)
但是你可以根据你的组织添加新的隶属关系
await caClient.newAffiliationService().create({ "name": "AFFILIATION_NAME }, adminObj)
Run Code Online (Sandbox Code Playgroud)