ecsoya / fabric-demo

Spring Fabric Demo
20 stars 10 forks source link

Service startup failed:The gateway identity must be set #1

Closed dwusiq closed 4 years ago

dwusiq commented 4 years ago

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fabricService' defined in class path resource [io/github/ecsoya/fabric/boot/SpringFabricGatewayAutoConfigure.class]: Unsatisfied dependency expressed through method 'fabricService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fabricContext': Invocation of init method failed; nested exception is java.lang.IllegalStateException: The gateway identity must be set

ecsoya commented 4 years ago

Which version did you used? Please use the latest version 1.0.5 for 'fabric-explorer-spring-boot-strater'

dwusiq commented 4 years ago

Which version did you used? Please use the latest version 1.0.5 for 'fabric-explorer-spring-boot-strater'

yes,i use this:'io.github.ecsoya:fabric-explorer-spring-boot-starter:1.0.5' This is my configuration:

1

But can't find user admin:

2
ecsoya commented 4 years ago

It seems that your network config file has errors for loading the peer admin for Org1.

please check the 'connection-Org1.yml' and make sure that:

  1. client.organization = Org1
  2. organizations.Org1: the 'adminPrivateKey' and 'signedCert' pem of 'Org1' has been correctly loaded.

client: logging: level: debug connection: timeout: peer: endorser: 30000 eventHub: 30000 eventReg: 30000 orderer: 30000 organization: Org1 channels: ... organizations: Org1: mspid: Org1MSP certificateAuthorities:

dwusiq commented 4 years ago

It seems that your network config file has errors for loading the peer admin for Org1.

please check the 'connection-Org1.yml' and make sure that:

  1. client.organization = Org1
  2. organizations.Org1: the 'adminPrivateKey' and 'signedCert' pem of 'Org1' has been correctly loaded.

client: logging: level: debug connection: timeout: peer: endorser: 30000 eventHub: 30000 eventReg: 30000 orderer: 30000 organization: Org1 channels: ... organizations: Org1: mspid: Org1MSP certificateAuthorities:

  • ca.Org1.example.com adminPrivateKey: pem: | -----BEGIN PRIVATE KEY-----
        -----END PRIVATE KEY-----
  **signedCert**:
     pem: |
        -----BEGIN CERTIFICATE-----
        -----END CERTIFICATE-----
  peers:
  - peer0.Org1.example.com
  - peer1.Org1.example.com

The channel I built based on the online tutorial, found that the connection-org1.yaml file does not have adminPrivateKey. Is there any way to generate adminPrivateKey?

ecsoya commented 4 years ago

You must build your fabric network firstly.

https://ecsoya.github.io/fabric/pages/demo.html

Fabric 网络搭建 1- 运行first-network文件夹中的byfn.sh脚本,此方法为官方的fabric-samples中的示例,做了少量修改。

./byfn.sh up -a -s couchdb 2- 具体的修改如下: 为了安装通用链码,几处修改如下。

a. 由于将链码放到了src/chaincode目录下,所以在scripts/script.sh中对链码的位置做了相应的修改。

CC_SRC_PATH="github.com/chaincode/common/"

b. 同样的,将docker-composite-cli.yaml中关于链码的映射路径(83行)做了修改。

- ./../src/chaincode/:/opt/gopath/src/github.com/chaincode 

c. 修改了utils.sh中执行Chaincode的默认的initinvokequery方法。

1. invoke -> create
2. query -> get

3- 生成Fabric网络配置文件

运行src/main/test中的NetworkGenerator文件,在src/main/resource/network中生成connection-Org1.yml及connection-Org2.yml文件。

关于Fabric网络配置文件的相关信息,请参考文档Fabric Network Config。

dwusiq commented 4 years ago

connection-org1.yaml的organizations这样配置就可以启动了,但是页面没有数据 organizations: Org1: mspid: Org1MSP peers:

3
ecsoya commented 4 years ago

这个看起来还是证书加载的问题。

我看你加载证书用的是路径path,没有用pem,这样Fabric SDK在加载证书时会遇到证书加载不上的问题。

pem其实就是证书的内容,你可以直接把你的证书里面的文本粘贴到里面就可以了。

dwusiq commented 4 years ago

是证书问题,可能是因为我昨天换了个命令重启fabric网络导致证书变了,我从服务器重新下载证书就可以了。非常感谢哈

2
ecsoya commented 4 years ago

不客气,解决了就好,每次部署完证书都会变。