I'm newbie to Hyperledger Fabric. When i instantiate the chaincode written in java after installed on peers from the cli container, there is something wrong:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.github.everit-org.json-schema:org.everit.json.schema:1.11.1.
Searched in the following locations:
file:/root/.m2/repository/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.pom
file:/root/.m2/repository/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.jar
https://repo.maven.apache.org/maven2/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.pom
https://repo.maven.apache.org/maven2/com/github/everit-org/json-schema/org.everit.json.schema/1.11.1/org.everit.json.schema-1.11.1.jar
Required by:
project : > org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.2
I thought it might be the maven repository's issue, but when i use gradle in my host's terminal, it runs ok like:
fabric@ubuntu:~/fabric1.4/fabric-samples/chaincode/master-liuqi/java$ sudo /opt/gradle/bin/gradle -b build.gradle build
Task :compileJava
Note: /home/fabric/fabric1.4/fabric-samples/chaincode/master-liuqi/java/src/main/java/org/hyperledger/fabric/example/SimpleChaincode.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 executed
below is my build.gradle, It is the same as the hyperleger's example chaincode.
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.3'
id 'java'
}
group 'org.hyperledger.fabric-chaincode-java'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.+'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
shadowJar {
baseName = 'chaincode'
version = null
classifier = null
manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleChaincode'
}
}
Is there any way to solve this problem? and what is the difference in running gradle build within host and container?
I searched the maven repository(https://mvnrepository.com/artifact/org.hyperledger.fabric-chaincode-java/fabric-chaincode-shim/1.4.2), found that this dependency is not in maven central repository. After adding repository in build.gradle as follows:
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://repository.mulesoft.org/nexus/content/repositories/public/"
}
}
it works well now. since i am not familar with gradle, i still wonder why i can build successfully in host while failed in cli container ?