Failed to import the business network card

2019-08-24 04:20发布

问题:

When I tried to import a business network card using the command "composer card import -f PeerAdmin@byfn-network-org1-only.card" it shows the following error message.

Failed to import the business network card keyword: required dataPath:
schemaPath: #/required params: missingProperty: x-type message: should have required property 'x-type' keyword: required dataPath:
schemaPath: #/required params: missingProperty: client message: should have required property 'client' keyword: required dataPath:
schemaPath: #/required params: missingProperty: certificateAuthorities message: should have required property 'certificateAuthorities' keyword: required dataPath:
schemaPath: #/required params: missingProperty: channels message: should have required property 'channels' keyword: type dataPath: .orderers schemaPath: #/type params: type: object message: should be object keyword: type dataPath: .peers schemaPath: #/type params: type: object message: should be object Error: Errors found in the connection profile in the card Command failed

My FABRIC_VERSION is set as following
FABRIC_VERSION=hlfv11

composer version is v0.19.5

The content of connection.json is shown below.

{
"name": "byfn-network-org1-only",
"type": "hlfv11",
"mspID": "Org1MSP",
"peers": [
    {
        "requestURL": "grpcs://localhost:7051",
        "eventURL": "grpcs://localhost:7053",
        "cert": "/home/koosh/fabric-tools/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
        "hostnameOverride": "peer0.org1.example.com"
    },
    {
        "requestURL": "grpcs://localhost:8051",
        "eventURL": "grpcs://localhost:8053",
        "cert": "/home/koosh/fabric-tools/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
        "hostnameOverride": "peer1.org1.example.com"
    }
],
"ca": {
    "url": "https://localhost:7054",
    "name": "ca-org1",
    "cert": "/home/koosh/fabric-tools/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
    "hostnameOverride": "ca.org1.example.com"
},
"orderers": [
    {
        "url" : "grpcs://localhost:7050",
        "cert": "/home/koosh/fabric-tools/fabric-samples/first-network/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt",
        "hostnameOverride": "orderer.example.com"
    }
],
"channel": "mychannel",
"timeout": 300

}

What is the issue here?
What should I change to support cards based on this connection file format? If I change the connection format to older version, it will work. But how can I use the same format?

回答1:

You have to write "x-type": "hlfv11" instead of "type": "hlfv11".



回答2:

The format of the connection profile you have presented here is in a Composer 0.16.x format (and is also slightly incorrect as there is no supported type of hlfv11.

As you are trying to use a newer release of Composer you need to define a connection profile in a new format. The reference to that format can be found here

https://hyperledger.github.io/composer/latest/reference/connectionprofile

The Composer tutorials also provide more information about connection profiles

https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-single-org https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-multi-org