I am trying to connect kotlin app based on gradle to mssql database (via modules hikari & hibernate fw).
When I run kotlin app in IDE (intellij Idea), everything works fine, but when I compile it via gradlew, it throws exception, that it is missing driver and I don`t know, how to embed it into jar. I've tried googling, found something about adding driver into classpath of jar, but no luck.
Tried driver compile group: 'net.sourceforge.jtds', name: 'jtds', version: '1.3.1' in dependencies, but no luck either.
The module with database handler has build.gradle
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
kotlinVersion = '1.1.50'
jUnitVersion = '4.12'
jacksonVersion = '2.8.6'
networkntVersion = '0.1.7'
jsoupVersion = '1.10.3'
slf4jVersion = '1.7.21'
elasticSearchVersion = '5.6.5'
hikariCpVersion = '2.6.1'
hibernateVersion = '5.2.10.Final'
redisVersion = '2.9.0'
mysqlVersion = '6.0.6'
jtdsVersion = '1.3.1'
rabbitMqVersion = '4.2.0'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
/* BUILDSCRIPT */
buildscript {
ext.kotlinVersion = '1.1.50'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlinVersion"
}
}
repositories { mavenCentral() }
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
testCompile group: 'junit', name: 'junit', version: "$jUnitVersion"
// kotlin-reflect as explicit dependency because of compilation errors in gradle
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: "$jacksonVersion"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "$jacksonVersion"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "$jacksonVersion"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-kotlin
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: "$jacksonVersion"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: "$jacksonVersion"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: "$jacksonVersion"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: "$jacksonVersion"
// json schema validator (based on jackson)
compile group: 'com.networknt', name: 'json-schema-validator', version: "$networkntVersion"
// html parser
compile "org.jsoup:jsoup:$jsoupVersion"
// logging
compile group: 'org.slf4j', name: 'slf4j-api', version: "$slf4jVersion"
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: "$slf4jVersion"
// ckf.upe.common.elastic
// https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch
// https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.6/transport-client.html
compile group: 'org.elasticsearch.client', name: 'transport', version: "$elasticSearchVersion"
// ckf.upe.common.database
// connection pool
// https://github.com/brettwooldridge/HikariCP
compile group: 'com.zaxxer', name: 'HikariCP', version: "$hikariCpVersion"
// hibernate
compile group: 'org.hibernate', name: 'hibernate-core', version: "$hibernateVersion"
// hibernate-hikaricp
// https://mvnrepository.com/artifact/org.hibernate/hibernate-hikaricp
compile group: 'org.hibernate', name: 'hibernate-hikaricp', version: "$hibernateVersion"
// https://mvnrepository.com/artifact/redis.clients/jedis
// https://github.com/xetorthio/jedis
compile group: 'redis.clients', name: 'jedis', version: "$redisVersion"
}
exception thrown when running jar file is:
Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:271)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:691)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
at ckf.upe.application.App.getSessionFactory(App.kt:104)
at ckf.upe.fischer.database.MappingRepository.sessionFactory(MappingRepository.kt:13)
at ckf.upe.common.sql.AbstractRepository.withSession(AbstractRepository.kt:21)
at ckf.upe.mapping.service.MappingService.loadMapping(MappingService.kt:33)
at ckf.upe.application.upe.MainKt.main(main.kt:41)
Caused by: org.hibernate.HibernateException: java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:jtds:sqlserver://devsql2.fischer:1433/CKFischer_Mapping_PROD;useLOBs=false
at org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure(HikariCPConnectionProvider.java:63)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
... 18 more
Caused by: java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:jtds:sqlserver://devsql2.fischer:1433/CKFischer_Mapping_PROD;useLOBs=false
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:88)
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:323)
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:114)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:105)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:72)
at org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure(HikariCPConnectionProvider.java:59)
... 26 more
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(Unknown Source)
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:81)
... 31 more
OK, found the solution as #Hannes mentioned, you need explicitly instantiate driver like Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance() in your app. More info here:
jtds.sourceforge.net/faq.html
Related
I have recently moved an enterprise CorDapp to a different machine running Ubuntu. I have install all the correct dependencies as described in the docs. When I initially run ./gradlew clean deployNodes, everything builds fine. However, when I do subsequent builds, I keep getting the error:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cordapp-source:deployNodes'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.IllegalStateException: Error while generating node info file. Please check the logs in /home/ubuntu/cordapp/cordapp-source/build/nodes/Node1/logs.
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion.generateNodeInfo(NetworkBootstrapper.kt:112)
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion.access$generateNodeInfo(NetworkBootstrapper.kt:71)
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion$generateNodeInfos$1$1.invoke(NetworkBootstrapper.kt:95)
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion$generateNodeInfos$1$1.invoke(NetworkBootstrapper.kt:71)
at net.corda.core.internal.concurrent.ValueOrException$DefaultImpls.capture(CordaFutureImpl.kt:140)
at net.corda.core.internal.concurrent.OpenFuture$DefaultImpls.capture(CordaFutureImpl.kt)
at net.corda.core.internal.concurrent.CordaFutureImpl.capture(CordaFutureImpl.kt:152)
at net.corda.core.internal.concurrent.CordaFutureImplKt$fork$$inlined$also$lambda$1.run(CordaFutureImpl.kt:32)
Suppressed: java.lang.IllegalStateException: Error while generating node info file. Please check the logs in /home/ubuntu/cordapp/cordapp-source/build/nodes/Node2/logs.
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion.generateNodeInfo(NetworkBootstrapper.kt:112)
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion.access$generateNodeInfo(NetworkBootstrapper.kt:71)
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion$generateNodeInfos$1$1.invoke(NetworkBootstrapper.kt:95)
at net.corda.nodeapi.internal.network.NetworkBootstrapper$Companion$generateNodeInfos$1$1.invoke(NetworkBootstrapper.kt:71)
at net.corda.core.internal.concurrent.ValueOrException$DefaultImpls.capture(CordaFutureImpl.kt:140)
at net.corda.core.internal.concurrent.OpenFuture$DefaultImpls.capture(CordaFutureImpl.kt)
at net.corda.core.internal.concurrent.CordaFutureImpl.capture(CordaFutureImpl.kt:152)
at net.corda.core.internal.concurrent.CordaFutureImplKt$fork$$inlined$also$lambda$1.run(CordaFutureImpl.kt:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Furthermore, the log files for the nodes are mostly empty and don't give any clue as to what is going on. Initially I thought it may be to do with heap size as this new machine has 8 cores but I don't get any 'out of memory' errors. Any suggestions as to where to look would be greatly appreciated!
Below are the build.gradle files I am using:
In build.gradle:
buildscript {
ext.corda_release_distribution = 'com.r3.corda'
ext.corda_release_version = '3.1'
ext.corda_gradle_plugins_version = '4.0.25'
ext.kotlin_version = '1.2.50'
ext.junit_version = '4.12'
ext.okhttp_version = '3.5.0'
ext.commons_validator_version = '1.4.1'
ext.joda_version = '2.9.9'
ext.aws_java_sdk_version = '1.11.228'
ext.apache_tika_version = '1.11'
ext.postgresql_version = '42.2.2'
ext.rabbitmq_amqp_version = '3.3.4'
ext.spring_boot_version = '2.0.2.RELEASE'
ext.spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version"
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/exposed' }
maven { url 'https://jitpack.io' }
}
}
In src/build.grade:
apply plugin: 'kotlin'
apply plugin: 'net.corda.plugins.cordapp'
apply plugin: 'net.corda.plugins.cordformation'
apply plugin: 'net.corda.plugins.quasar-utils'
jar.baseName = "test-ledger"
sourceSets {
main {
resources {
srcDir "../config/dev"
}
}
test {
resources {
srcDir "../config/test"
}
}
integrationTest {
kotlin {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/kotlin')
}
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile "junit:junit:$junit_version"
// Corda integration dependencies
cordaCompile "$corda_release_distribution:corda-core:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-finance:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-jackson:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-rpc:$corda_release_version"
cordaRuntime "$corda_release_distribution:corda:$corda_release_version"
testCompile "$corda_release_distribution:corda-node-driver:$corda_release_version"
// CorDapp dependencies
cordapp "$corda_release_distribution:corda-finance:$corda_release_version"
compile "org.postgresql:postgresql:$postgresql_version"
compile "commons-validator:commons-validator:$commons_validator_version"
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
compile "joda-time:joda-time:$joda_version"
compile "com.amazonaws:aws-java-sdk-s3:$aws_java_sdk_version"
compile "org.apache.tika:tika-core:$apache_tika_version"
compile "com.rabbitmq:amqp-client:$rabbitmq_amqp_version"
}
task integrationTest(type: Test, dependsOn: []) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
languageVersion = "1.1"
apiVersion = "1.1"
jvmTarget = "1.8"
javaParameters = true // Useful for reflection.
}
}
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
node {
name "O=Notary,L=Sydney,C=AU"
notary = [validating : false]
p2pPort 10002
rpcSettings {
address("localhost:10003")
adminAddress("localhost:10043")
}
cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version"]
}
node {
name "O=Node1,L=Sydney,C=AU"
p2pPort 10005
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version"]
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
}
node {
name "O=Node2,L=Sydney,C=AU"
p2pPort 10008
rpcSettings {
address("localhost:10009")
adminAddress("localhost:10049")
}
cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version"]
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
}
}
Below is the only change that I make to the build.gradle file to shift from Enterprise to Open Source which runs as expected (I can keep running ./gradlew clean deployNodes).
ext.corda_release_distribution = 'net.corda'
ext.corda_release_version = '3.2-corda'
ext.corda_gradle_plugins_version = '3.1.0'
ext.kotlin_version = '1.1.60'
ext.junit_version = '4.12'
ext.quasar_version = '0.7.9'
Try removing the the "clean" task from ./gradlew clean build
What version of Gradle are you using? We have noticed that unless you are using 4.8 or 4.9 the build fails. You may try to see what your Gradle wrapper is specifying.
I was trying to configure my test cases in VSapp center, my tests are written in appium. Followed the following steps:
Step 1# Added the JCenter repository enabled in the build.gradle in my project's root folder. build.gradle file is like following
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Step 2# Added the androidTestCompile('com.microsoft.appcenter:appium-test-extension:1.0') in build.gradle file inside app folder
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.keya.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('com.microsoft.appcenter:appium-test-extension:1.0')
def appCenterSdkVersion = '1.1.0'
compile "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
compile "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'org.assertj:assertj-core:2.0.0'
testCompile 'org.testng:testng:6.8.8'
compile files('libs/apache-mime4j-0.6.jar')
compile files('libs/commons-codec-1.10.jar')
compile files('libs/commons-collections-3.2.1.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/commons-exec-1.3.jar')
compile files('libs/commons-lang3-3.4.jar')
compile files('libs/commons-logging-1.1.3.jar')
compile files('libs/commons-validator-1.4.1.jar')
compile files('libs/gson-2.3.1.jar')
compile files('libs/guava-18.0.jar')
compile files('libs/httpclient-4.4.1.jar')
compile files('libs/httpcore-4.4.1.jar')
compile files('libs/httpmime-4.4.1.jar')
compile 'com.android.support:support-annotations:25.0.1'
compile group: 'com.beust', name: 'jcommander', version: '1.27'
testCompile 'info.cukes:cucumber-java:1.2.5'
testCompile 'info.cukes:cucumber-junit:1.2.5'
testCompile 'info.cukes:cucumber-picocontainer:1.2.2'
compile 'com.android.support:support-v4:25.0.1'
}
apply plugin: 'maven'
task createPom {
pom {
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
//Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.testCompile.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
def profilesNode = asNode().appendNode('profiles')
profilesNode.append(new XmlParser().parse('https://raw.githubusercontent.com/Microsoft/AppCenter-Test-Appium-Java-Extensions/master/gradleuploadprofilesnippet.xml'))
}
}.writeTo("pom.xml")}
within this step, everything was successful build was successful but when I was trying to import the following libs
import com.microsoft.appcenter.appium.Factory;
import com.microsoft.appcenter.appium.EnhancedAndroidDriver;
Application failed to import
Step3# I also tried to import the libs using mvn --> This step didnt work.
Application is showing Can not resolve symbol message
Can any one suggest me the solution?
Found the solution of the problem, just simply added the jar as library in build path and its working fine
I follow the steps in the google developers, and I can run the sign-in demo.
Add the dependency to your project-level build.gradle
classpath 'com.google.gms:google-services:3.0.0'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
In your app-level build.gradle file, declare Google Play Services as a dependency:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services-auth:9.8.0'
}
Here's my project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's my app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "net.kdapp.partygor"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
jniDebuggable false
//signingConfig signingConfigs.cic
renderscriptDebuggable false
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
//signingConfig signingConfigs.cic
minifyEnabled true
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// 日曆視圖自定義 view
// 雙向 seekBar
// 輪播圖
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.ashokvarma.android:bottom-navigation-bar:1.3.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.zhy:okhttputils:2.6.2'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
compile 'com.youth.banner:banner:1.4.9'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
// Dependency for Google Sign-In
compile 'com.google.android.gms:play-services-auth:11.0.1'
testCompile 'junit:junit:4.12'
compile project(':redpacketlibrary')
compile project(':easeui')
compile project(path: ':pickerview')
compile files('libs/parse-android-1.13.0.jar')
compile files('libs/android-support-multidex.jar')
}
apply plugin: 'com.google.gms.google-services'
But when I run my project, I get this error.
08-04 09:34:45.420 22456-22456/net.kdapp.partygor E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.kdapp.partygor, PID: 22456
java.lang.NoSuchFieldError: No static field zzazX of type Lcom/google/android/gms/common/ConnectionResult; in class Lcom/google/android/gms/common/ConnectionResult; or its superclasses (declaration of 'com.google.android.gms.common.ConnectionResult' appears in /data/data/net.kdapp.partygor/files/instant-run/dex/slice-google-play-services_78c2c5fe145c1c95c9696f0679d986433b0c2b89-classes.dex)
at com.google.android.gms.common.internal.zzo.zzrj(Unknown Source)
at com.google.android.gms.common.internal.zze.zzs(Unknown Source)
at com.google.android.gms.common.internal.zzi.zzrk(Unknown Source)
at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5877)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1019)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814)
I search in google many times and change the google-services api version, but it still didn't work.
I'm trying to override copy task using load-grunt-config.
In my Gruntfile.js I have copy task that I want to override by custom copy task.
In Gruntfile.js also I have this configuration for load-grunt-config:
require('load-grunt-config')(grunt, {
configPath: path.join(process.cwd(), 'grunt/config'),
jitGrunt: {
customTasksDir: 'grunt/tasks'
}
});
This is grunt/config/copy.js content:
module.exports = {
main: {
src: 'test/*',
dest: 'copyTest'
};
And here is grunt/tasks/default.js content:
module.exports = function (grunt) {
grunt.registerTask('default', ['copy:main']);
};
When I run the default task I got error:
Loading "copy.js" tasks...OK
+ copy
Running "copy:main" (copy) task
Verifying property copy.main exists in config...ERROR
>> Unable to process task.
Warning: Required config property "copy.main" missing. Use --force to continue.
Aborted due to warnings.
Any idea what could be wrong?
I have cloned the corda-training-template repo and had wanted to test signature constraints in Corda v4.x. Rather than getting a test key to sign the jar, I would go for the default corda dev key for convenience. However my understanding is that corda dev key is used as default if you don't put in any custom credentials, so that all jars are signed with it. However it keep printing out the error message during build as:
* What went wrong:
Execution failed for task ':kotlin-source:jar'. > Exception while signing kotlin-source-0.1.jar, ensure the 'cordapp.signing.options' entry contains correct keyStore configuration, or disable signing by 'cordapp.signing.enabled false'. Run with --info or --debug option and search for 'ant:signjar' in log output.
The following is the original build.gradle for the kotlin-source with signing enable false removed:
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/exposed' }
maven { url 'https://jitpack.io' }
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases' }
}
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'net.corda.plugins.cordapp'
apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'net.corda.plugins.cordformation'
apply plugin: 'net.corda.plugins.quasar-utils'
apply plugin: 'maven-publish'
cordapp {
targetPlatformVersion 4
minimumPlatformVersion 3
contract {
name "Corda Training Material"
vendor "R3"
licence "Contact R3 for Kotlin Source Contract License."
versionId 1
}
workflow {
name "Corda Training Material"
vendor "R3"
licence "Contact R3 for Kotlin Source Workflow License."
versionId 1
}
}
sourceSets {
main {
resources {
srcDir "../config/dev"
}
}
test {
resources {
srcDir "../config/test"
}
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile "junit:junit:$junit_version"
// Corda integration dependencies
cordaCompile "$corda_release_distribution:corda-core:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-finance-contracts:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-finance-workflows:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-jackson:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-rpc:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-node-api:$corda_release_version"
cordaCompile "$corda_release_distribution:corda-webserver-impl:$corda_release_version"
cordaRuntime "$corda_release_distribution:corda:$corda_release_version"
cordaRuntime "$corda_release_distribution:corda-webserver:$corda_release_version"
testCompile "$corda_release_distribution:corda-test-utils:$corda_release_version"
testCompile "$corda_release_distribution:corda-node-driver:$corda_release_version"
// GraphStream: For visualisation (required by TemplateClientRPC app)
compile "org.graphstream:gs-core:1.3"
compile("org.graphstream:gs-ui:1.3") {
exclude group: "bouncycastle"
}
// CorDapp dependencies
// Specify your cordapp's dependencies below, including dependent cordapps
cordapp "$corda_release_distribution:corda-finance-contracts:$corda_release_version"
cordapp "$corda_release_distribution:corda-finance-workflows:$corda_release_version"
cordapp "$corda_release_distribution:corda-confidential-identities:$corda_release_version"
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
languageVersion = "1.2"
apiVersion = "1.2"
jvmTarget = "1.8"
javaParameters = true // Useful for reflection.
}
}
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
delete "./build/nodes"
directory "./build/nodes"
nodeDefaults {
cordapp("$corda_release_distribution:corda-finance-contracts:$corda_release_version")
cordapp("$corda_release_distribution:corda-finance-workflows:$corda_release_version")
cordapp("$corda_release_distribution:corda-confidential-identities:$corda_release_version")
rpcUsers = [[ user: "user1", "password": "password", "permissions": ["ALL"]]]
}
node {
name "O=Notary,L=London,C=GB"
notary = [validating: false]
p2pPort 10002
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10003"
adminAddress "0.0.0.0:10103"
}
}
node {
name "O=ParticipantA,L=London,C=GB"
p2pPort 10007
webPort 10009
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10008"
adminAddress "0.0.0.0:10108"
}
}
node {
name "O=ParticipantB,L=New York,C=US"
p2pPort 10010
webPort 10012
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10011"
adminAddress "0.0.0.0:10111"
}
}
node {
name "O=ParticipantC,L=Paris,C=FR"
p2pPort 10013
webPort 10015
rpcSettings {
useSsl false
standAloneBroker false
address "0.0.0.0:10014"
adminAddress "0.0.0.0:10114"
}
}
}
idea {
module {
downloadJavadoc = true // defaults to false
downloadSources = true
}
}
In response to the error message, i have added the following to the build.gradle under both cordapp (https://docs.corda.net/releases/release-V4.0/cordapp-build-systems.html#signing-the-cordapp-jar) and deployNodes (https://docs.corda.net/releases/release-V4.0/generating-a-node.html#signing-cordapp-jars) task in different permutations but the same error message asking for right keystore configuration keeps showing up:
signing {
enabled true
options {
keystore
alias
storepass
storetype
keyalg
}
}
Without the mentioning about the credentials of the keystore or even specifying signing options, corda should build the jar with the default corda dev keys, but it isn't the case.
For a start the error message is misleading and doesn't say exactly what is happening within the java jarsigner tool (see ant signjar). Instead there is a likelihood that there is a problem with the jar such that jarsigner is unable to sign. SignJar.kt (Line 23 to 24) from the corda core plugin throws a generic error message when it encounters an error, so one would need to run the jar tasks with either --info or --debug mode, followed by scanning the messages for [ant:signjar].
In my encounter following running the jar signing task with --debug mode, showed an error message of the following:
01:00:15.040 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:signjar] jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry: META-INF/LICENSE.txt
Likely the problem is while trying to fatjar (with other libs), the license files from other jars are causing a conflict. The resolution in my case is to exclude the license file from my build. Add the following to the build.gradle jar task.
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
After i have build the jar, I used the jarsigner tool (include in your JDK) to verify if the jar has been signed.
jarsigner -verify <your jar.file name>
If its signed, it will output the following:
jar verified.
Warning:
This jar contains entries whose certificate chain is not validated.
This jar contains entries whose signer certificate will expire within six months.
This jar contains signatures that does not include a timestamp. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2019-11-26) or after any future revocation date.
Re-run with the -verbose and -certs options for more details.