Cannot run Spark job with Cassandra driver - apache-spark

build.gradle
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '1.2.3'
}
group 'com.hello.aggregation'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'idea'
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
}
repositories {
mavenCentral()
}
dependencies {
compile "org.scala-lang:scala-library:$scalaVersion"
compile "org.scala-lang:scala-reflect:$scalaVersion"
compile "org.scala-lang:scala-compiler:$scalaVersion"
compile "org.apache.spark:spark-core_$scalaBase:$sparkVersion"
compile "org.apache.spark:spark-sql_$scalaBase:$sparkVersion"
compile "com.datastax.cassandra:cassandra-driver-core:$cassandraDriverVersion"
compile "com.datastax.spark:spark-cassandra-connector_$scalaBase:$connectorVersion"
compile "org.slf4j:slf4j-api:$slf4jVersion"
compile "mysql:mysql-connector-java:$mySqlConnectorVersion"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
task run(type: JavaExec, dependsOn: classes) {
main = mainClassFile
classpath sourceSets.main.runtimeClasspath
classpath configurations.runtime
}
jar {
classifier = 'all'
manifest {
attributes 'Implementation-Title': title,
'Implementation-Version': version,
'Main-Class': mainClassFile
}
include{sourceSets.main.output.classesDir}
zip64 true
}
shadowJar {
classifier = 'shadow'
append 'reference.conf'
dependencies {
}
zip64 true
}
idea {
module {
// IntelliJ does not know about the standard idiom of provided as used in managing
// uber/shaded jar dependencies. Make it so!
scopes.PROVIDED.plus += [ configurations.provided ]
}
}
gradle.properties
version=1.0.0
scalaBase=2.11
scalaVersion=2.11.4
slf4jVersion=1.7.25
sparkVersion=1.6.3
connectorVersion=1.6.7
cassandraDriverVersion=3.0.7
mySqlConnectorVersion=5.1.37
exception:
17/06/19 16:03:54 INFO BlockManagerMaster: Registered BlockManager
Exception in thread "main" java.lang.NoSuchMethodError: scala.runtime.ObjectRef.zero()Lscala/runtime/ObjectRef;
at com.datastax.spark.connector.cql.CassandraConnector$.com$datastax$spark$connector$cql$CassandraConnector$$createSession(CassandraConnector.scala)
at com.datastax.spark.connector.cql.CassandraConnector$$anonfun$7.apply(CassandraConnector.scala:150)
at com.datastax.spark.connector.cql.CassandraConnector$$anonfun$7.apply(CassandraConnector.scala:150)
at com.datastax.spark.connector.cql.RefCountedCache.createNewValueAndKeys(RefCountedCache.scala:32)
at com.datastax.spark.connector.cql.RefCountedCache.syncAcquire(RefCountedCache.scala:69)
at com.datastax.spark.connector.cql.RefCountedCache.acquire(RefCountedCache.scala:57)
at com.datastax.spark.connector.cql.CassandraConnector.openSession(CassandraConnector.scala:80)
at com.datastax.spark.connector.cql.CassandraConnector.withSessionDo(CassandraConnector.scala:107)
at com.datastax.spark.connector.cql.CassandraConnector.withClusterDo(CassandraConnector.scala:118)
at com.datastax.spark.connector.cql.Schema$.fromCassandra(Schema.scala:330)
at com.datastax.spark.connector.cql.Schema$.tableFromCassandra(Schema.scala:350)
at com.datastax.spark.connector.rdd.CassandraTableRowReaderProvider$class.tableDef(CassandraTableRowReaderProvider.scala:50)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.tableDef$lzycompute(CassandraTableScanRDD.scala:60)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.tableDef(CassandraTableScanRDD.scala:60)
at com.datastax.spark.connector.rdd.CassandraTableRowReaderProvider$class.verify(CassandraTableRowReaderProvider.scala:137)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.verify(CassandraTableScanRDD.scala:60)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.getPartitions(CassandraTableScanRDD.scala:230)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237)
at scala.Option.getOrElse(Option.scala:120)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:237)
at org.apache.spark.rdd.RDD$$anonfun$distinct$2.apply(RDD.scala:359)
at org.apache.spark.rdd.RDD$$anonfun$distinct$2.apply(RDD.scala:359)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:111)
at org.apache.spark.rdd.RDD.withScope(RDD.scala:316)
at org.apache.spark.rdd.RDD.distinct(RDD.scala:358)
at com.achoo.scala.streambright.SimpleDailyRun$.delayedEndpoint$com$achoo$scala$streambright$SimpleDailyRun$1(SimpleDailyRun.scala:30)
at com.achoo.scala.streambright.SimpleDailyRun$delayedInit$body.apply(SimpleDailyRun.scala:14)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
Code:
package com.streambright
import java.sql.{Connection, DriverManager}
import com.mysql.jdbc.Driver
import org.apache.spark.rdd.JdbcRDD
import org.apache.spark.{SparkConf, SparkContext}
import com.datastax.spark.connector.toSparkContextFunctions
import org.apache.spark.sql.cassandra.CassandraSQLContext
object SimpleDailyRun extends App {
DriverManager.registerDriver(new Driver())
val config = new SparkConf(true).setAppName("Simple Daily Run")
val sc = SparkContext.getOrCreate(config)
val cc = new CassandraSQLContext(sc)
cc.setKeyspace("achoo")
val conn = DriverManager.getConnection("jdbc:mysql://10.175.190.95/db?useUnicode=yes&characterEncoding=UTF-8&user=user&password=pass")
val mySqlJdbcRDD = new JdbcRDD(sc, () => conn,
"SELECT b.project_id,a.keyword FROM keyword a " +
"JOIN project_keyword b ON a.id = b.keyword_id LIMIT ?, ?",
0, 100000000, 1, r => (r.getInt("project_id"), r.getString("keyword")))
val cassandraRDD = sc.cassandraTable("hello", "instagram_keyword_analytic")
.select("keyword", "relativepath")
.as((_: String, _: String))
.distinct()
mySqlJdbcRDD.saveAsTextFile("/data/MySQL_projectid_keywords_"+System.currentTimeMillis()+".txt")
cassandraRDD.saveAsTextFile("/data/MySQL_projectid_keywords_"+System.currentTimeMillis()+".txt")
}
Cassandra version: cassandra21-2.1.15-1 (DataStax)
Spark version: 1.6.3
Does anybody know how to fix this?

The fix for this problem is to use Scala 2.10 instead of 2.11.

Related

Liquibase Hibernate missing SequenceStyleGenerator.generatorKey() error

I am trying to generate a diff changelog using Liquibase and Hibernate but when I run the command gradle diffChangeLog I get the following error:
ERROR [liquibase.integration.commandline.Main]: Unexpected error running Liquibase: 'java.lang.Object org.hibernate.id.enhanced.SequenceStyleGenerator.generatorKey()'
java.lang.NoSuchMethodError: 'java.lang.Object org.hibernate.id.enhanced.SequenceStyleGenerator.generatorKey()'
I am able to generate a changelog, but only get issues when trying to generate a diff changelog. My build.gradle.kts file is below:
plugins {
java
id("org.springframework.boot") version "2.6.2"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("org.liquibase.gradle") version "2.1.1"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
var sourceCompatibility = "11"
val postgresVersion = "42.2.19"
val liquibaseVersion = "2.1.1"
val lombokVersion = "1.18.20"
val liquibaseCoreVersion = "3.8.4"
val liquibaseExtVersion = "5:3.8"
val hibernateCoreVersion= "5.4.10.Final"
repositories {
mavenCentral()
maven {
url = uri("https://repo.spring.io/milestone")
}
maven {
url = uri("https://repo.spring.io/snapshot")
}
}
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath("net.ltgt.gradle:gradle-apt-plugin:0.18")
classpath("org.postgresql:postgresql:42.2.9")
classpath("org.liquibase.ext:liquibase-hibernate5:3.8")
classpath("org.liquibase:liquibase-core:3.8.4")
classpath("org.liquibase:liquibase-gradle-plugin:2.0.2")
classpath("org.springframework.data:spring-data-jpa:2.2.1.RELEASE")
}
}
dependencies {
implementation("org.jetbrains:annotations:20.1.0")
runtimeOnly("org.postgresql:postgresql")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
// implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.postgresql:postgresql:$postgresVersion")
implementation("org.springframework.boot:spring-boot-starter")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group= "junit", module= "junit")
}
//testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.hamcrest:hamcrest-library:2.2")
implementation("org.liquibase:liquibase-core:$liquibaseCoreVersion")
implementation("org.liquibase.ext:liquibase-hibernate$liquibaseExtVersion")
implementation("org.springframework.boot:spring-boot:2.6.2")
implementation("info.picocli:picocli:4.6.1")
implementation("org.liquibase:liquibase-groovy-dsl:3.0.0")
liquibaseRuntime("org.liquibase:liquibase-core:$liquibaseCoreVersion")
liquibaseRuntime("org.liquibase:liquibase-groovy-dsl:2.1.1")
liquibaseRuntime("org.postgresql:postgresql:$postgresVersion")
liquibaseRuntime("org.liquibase.ext:liquibase-hibernate$liquibaseExtVersion")
liquibaseRuntime(sourceSets.getByName("main").compileClasspath)
liquibaseRuntime(sourceSets.getByName("main").runtimeClasspath)
liquibaseRuntime(sourceSets.getByName("main").output)
compileOnly("org.projectlombok:lombok:$lombokVersion")
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
tasks {
// Use the native JUnit support of Gradle.
"test"(Test::class) {
useJUnitPlatform()
}
}
liquibase {
activities.register("main") {
this.arguments = mapOf(
"classpath" to "src/main/resources",
"driver" to "org.postgresql.Driver",
"logLevel" to "info",
"changeLogFile" to "src/main/resources/db/changelog/changes/changelog_002.xml",
"url" to "jdbc:postgresql://localhost:54320/postgres?currentSchema=schema",
"username" to "postgres",
"password" to "postgres",
"referenceUrl" to "hibernate:spring:com.example?dialect=org.hibernate.dialect.PostgreSQLDialect" +
"&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate." +
"SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=" +
"org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy")
}
}
I have tried to change the versioning around but then get an error saying the driver could not be found.
Any help would be greatly appreciated! Thank you

How can i downgrade the gradle on project kotlin multiplatform to use a Android Studio Stable version?

Recently i started to work on a kotlin multiplatform project, i did not have any previous experience when i started, and i got the project with its base already created. The developer that create the project had the ideia to use the compose library on android development part.
Then he quit the job, and i started in it.
But i choose to not use compose because of the rush on deliver the application.
So the project gradle version is currently on 6.8 and android plugin on 7.0.0-alpha05
but i want to downgrade to stop to use the Android Studio on Canary version, and use on a stable version. But when i downgrade the gradle i am getting this error:
A problem occurred configuring project ':shared'.
> Failed to notify project evaluation listener.
> /Users/jhonata/Documents/Projetos/Aurea/quicktendr-mgmt/shared/src/main/AndroidManifest.xml (No such file or directory)
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':shared'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:191)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at ...
gradle properties:
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
shared gradle:
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("com.android.library")
id("kotlin-parcelize")
id("dev.icerock.mobile.multiplatform-resources")
kotlin("plugin.serialization")
}
android {
configurations {
create("androidTestApi")
create("androidTestDebugApi")
create("androidTestReleaseApi")
create("testApi")
create("testDebugApi")
create("testReleaseApi")
}
}
kotlin {
// jvm()
android()
ios {
binaries {
framework {
baseName = "shared"
when (val target = this.compilation.target.name) {
"iosX64" -> {
export(Deps.Decompose.iosX64)
}
"iosArm64" -> {
export(Deps.Decompose.iosArm64)
}
else -> error("Unsupported target: $target")
}
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(Deps.Decompose.decompose)
api(Deps.coroutines)
implementation(Deps.ktxSerializationJson)
implementation(Deps.ktorCore)
implementation(Deps.ktorSerialization)
implementation(Deps.kissMeCommon)
implementation("ch.qos.logback:logback-classic:1.2.3")
implementation("dev.icerock.moko:mvvm-core:0.10.1")
implementation("dev.icerock.moko:mvvm-livedata:0.10.1")
api("dev.icerock.moko:resources:0.15.1")
api("dev.icerock.moko:mvvm:0.9.1")
implementation("io.ktor:ktor-client-logging:1.4.2")
implementation("io.ktor:ktor-client-auth:1.4.2")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
// val mobileMain by creating {
// dependsOn(commonMain)
// dependencies {
//
// }
// }
val androidMain by getting {
dependencies {
implementation(Deps.ktorAndroid)
implementation(Deps.kissMeAndroid)
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
}
}
val iosMain by getting {
dependencies {
implementation(Deps.ktorIOS)
implementation(Deps.kissMeIOS)
}
}
val iosTest by getting
// val jvmMain by getting {
// dependencies {
// implementation("io.ktor:ktor-client-okhttp:1.4.2")
// }
// }
named("iosX64Main") {
dependencies {
api(Deps.Decompose.iosX64)
}
}
named("iosArm64Main") {
dependencies {
api(Deps.Decompose.iosArm64)
}
}
}
}
multiplatformResources {
multiplatformResourcesPackage = "com.quicktendr.mgmt" // required
iosBaseLocalizationRegion = "es" // optional, default "en"
}
android {
compileSdkVersion(29)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(24)
targetSdkVersion(29)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)
gradle:
buildscript {
repositories {
gradlePluginPortal()
jcenter()
google()
mavenCentral()
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://dl.bintray.com/icerockdev/plugins")
}
dependencies {
val kotlinVersion = "1.4.31"
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
classpath("com.android.tools.build:gradle:4.2.1")
classpath("com.github.jengelman.gradle.plugins:shadow:5.2.0")
classpath("dev.icerock.moko:resources-generator:0.15.1")
classpath("com.google.gms:google-services:4.3.5")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.5.2")
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven("https://dl.bintray.com/arkivanov/maven")
maven("https://dl.bintray.com/icerockdev/moko")
maven("https://dl.bintray.com/netguru/maven/")
maven("https://repo.repsy.io/mvn/chrynan/public")
maven("https://jitpack.io")
}
}
If you just want to downgrade gradle, you can downgrade gradle in the gradle properties file which you posted.
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
You would need to set this to the latest version supported by Android Studio 4.2.1. There are also compatibility considerations with the Android gradle plugin. You can see a compatibility matrix for that here:
https://developer.android.com/studio/releases/gradle-plugin#4-2-0
Please be aware that if your project was using things like compose which relied on particular versions of AGP/Gradle, you might need to rewrite those pieces. It is okay to use the canary versions of android studio or recent versions of intellij - unless you are hitting some issue. You can use compose and old view classes together using AndroidView
https://developer.android.com/jetpack/compose/interop/interop-apis#views-in-compose

Scala, IntelliJ and Gradle dependencies

I am trying to change my project dependencies to Scala 2.11 as I am having troubles with 2.12. My current plugin installation is 2.12. How can I change everything to 2.11?
My project is built on Gradle and this is my build.gradle class:
group 'ics5114'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
idea {
project {
jdkName = '1.8'
languageLevel = '1.8'
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.spark', name: 'spark-core_2.11', version: '2.3.0'
compile group: 'org.apache.spark', name: 'spark-sql_2.11', version: '2.3.0'
compile group: 'org.apache.spark', name: 'spark-graphx_2.11', version: '2.3.0'
}
jar {
zip64 true
archiveName = "music-graph-spark.jar"
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes 'Main-Class': 'com.sparkTutorial.sparkSql.StackOverFlowSurvey'
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
}

NoSuchMethodError occurs when run spark-streaming job on kafka

I'm use spark-streaming to consume protobuf-formated-messages from kafka.
It works fine while the master was set to "local[2]", but when i change the master url to a real spark cluster's master url, I meet the following exception
Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 20.0 failed 4 times, most recent failure: Lost task 0.3 in stage 20.0 (TID 58, 10.0.5.155): java.lang.NoSuchMethodError: com.google.protobuf.CodedInputStream.readStringRequireUtf8()Ljava/lang/String;
at cn.xiaoman.eagleeye.Agent$Tag.<init>(Agent.java:83)
at cn.xiaoman.eagleeye.Agent$Tag.<init>(Agent.java:44)
at cn.xiaoman.eagleeye.Agent$Tag$1.parsePartialFrom(Agent.java:638)
at cn.xiaoman.eagleeye.Agent$Tag$1.parsePartialFrom(Agent.java:633)
at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:309)
at cn.xiaoman.eagleeye.Agent$Metric.<init>(Agent.java:797)
at cn.xiaoman.eagleeye.Agent$Metric.<init>(Agent.java:718)
at cn.xiaoman.eagleeye.Agent$Metric$1.parsePartialFrom(Agent.java:1754)
at cn.xiaoman.eagleeye.Agent$Metric$1.parsePartialFrom(Agent.java:1749)
at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:141)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:176)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:188)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:193)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
at cn.xiaoman.eagleeye.Agent$Metric.parseFrom(Agent.java:1058)
at cn.xiaoman.eagleeye.rtmetricprocessor.MetricDeserializer.deserialize(MetricDeserializer.java:25)
at cn.xiaoman.eagleeye.rtmetricprocessor.MetricDeserializer.deserialize(MetricDeserializer.java:14)
at org.apache.kafka.clients.consumer.internals.Fetcher.parseRecord(Fetcher.java:627)
at org.apache.kafka.clients.consumer.internals.Fetcher.parseFetchedData(Fetcher.java:548)
at org.apache.kafka.clients.consumer.internals.Fetcher.fetchedRecords(Fetcher.java:354)
at org.apache.kafka.clients.consumer.KafkaConsumer.pollOnce(KafkaConsumer.java:1000)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:938)
at org.apache.spark.streaming.kafka010.CachedKafkaConsumer.poll(CachedKafkaConsumer.scala:99)
at org.apache.spark.streaming.kafka010.CachedKafkaConsumer.get(CachedKafkaConsumer.scala:70)
at org.apache.spark.streaming.kafka010.KafkaRDD$KafkaRDDIterator.next(KafkaRDD.scala:227)
at org.apache.spark.streaming.kafka010.KafkaRDD$KafkaRDDIterator.next(KafkaRDD.scala:193)
at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:462)
at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:461)
at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:439)
at org.apache.spark.util.collection.ExternalSorter.insertAll(ExternalSorter.scala:192)
at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:63)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:79)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:47)
at org.apache.spark.scheduler.Task.run(Task.scala:86)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:274)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Versions:
spark: 2.11-2.0.2
kafka: 2.11-0.10.1.0
protobuf: 3.0.2
Because the task depends on protobuf 3, while the spark runtime depends on another protobuf version.
Solution: Edit build.gradle to relocate com.google.protobuf to another name using 'com.github.johnrengelman.shadow' plugin.
shadowJar {
relocate 'com.google.protobuf', 'shadow.google.protobuf'
}
edit: add full version build.gradle
group 'xxx'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'
apply plugin: 'com.google.protobuf'
apply plugin: 'com.github.johnrengelman.shadow'
sourceCompatibility = 1.8
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
// ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier
// gradle versions
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}
def grpcVersion = '1.0.2'
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
def sparkVersion = '2.0.2'
dependencies {
compile "org.apache.spark:spark-streaming_2.11:${sparkVersion}"
compile "org.apache.spark:spark-streaming-kafka-0-10_2.11:${sparkVersion}"
compile "org.apache.spark:spark-core_2.11:${sparkVersion}"
compile 'com.google.protobuf:protobuf-java:3.1.0'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.0'
testCompile 'junit:junit:4.11'
}
protobuf {
protoc {
// The version of protoc must match protobuf-java. If you don't depend on
// protobuf-java directly, you will be transitively depending on the
// protobuf-java version that grpc depends on.
artifact = 'com.google.protobuf:protoc:3.0.2'
}
// plugins {
// grpc {
// artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
// }
// }
// generateProtoTasks {
// all()*.plugins {
// grpc {
// // To generate deprecated interfaces and static bindService method,
// // turn the enable_deprecated option to true below:
// option 'enable_deprecated=false'
// }
// }
// }
}
idea {
module {
// Not using generatedSourceDirs because of
// https://discuss.gradle.org/t/support-for-intellij-2016/15294/8
sourceDirs += file("${projectDir}/build/generated/source/proto/main/java");
}
}
shadowJar {
zip64 true
relocate 'com.google.protobuf', 'shadow.google.protobuf'
}
mainClassName = "xxx.Main"

Execution failed for task ':bintrayUpload'. > Could not create version '1.1-Final TestApp': HTTP/1.1 400 Bad Request

I am working on one library project in android. I want to upload my library to the JCenter. I have created bintray account etc & followed all steps which are mentioned here.
I did below changes in my application module & library module.
Application Module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.testapp"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':testlib')
}
Library Module build.gradle
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven'
bintrayName = 'test-sdk'
publishedGroupId = 'in.test.sdk'
libraryName = 'testlib'
artifact = 'test-sdk'
libraryDescription = 'A wrapper for Facebook Native Like Button (LikeView) on Android'
siteUrl = 'https://github.com/xyz/testsdk'
gitUrl = 'https://github.com/xyz/testsdk.git'
libraryVersion = '1.0.0'
developerId = 'xyz'
developerName = 'xyz'
developerEmail = 'xyz#xyz.xyz'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
version = "1.0.0"
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// proguardFiles 'proguard-project.txt'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0'
compile files('libs/gson-2.3.1.jar')
compile files('libs/android-query-full.0.26.8.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/jackson-annotations-2.5.0.jar')
compile files('libs/javax.annotation.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/okhttp-2.3.0.jar')
compile files('libs/okio-1.3.0.jar')
compile files('libs/retrofit-1.9.0.jar')
}
Latest Project root 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:1.1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.bintray" version "1.2"
}
allprojects {
repositories {
jcenter()
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java'
}
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId 'in.freeb.sdk'
artifactId 'freeb-sdk'
version '1.0'
}
}
}
bintray {
user = 'ajay-spice'
key = '31317855920db8f7bc27f97730a8e9f99b6f707e'
publications = ['MyPublication']
pkg {
repo = 'maven'
name = 'freeb-sdk'
userOrg = 'ajay-spice'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/ajay-spice/freebsdk.git'
labels = ['gear', 'gore', 'gorilla']
publicDownloadNumbers = true
attributes= ['a': ['ay1', 'ay2'], 'b': ['bee'], c: 'cee'] //Optional package-level attributes
version {
name = '1.0-Final'
desc = 'FreeB 1.0 final'
vcsTag = '1.0.0'
attributes = ['freeb-sdk': 'in.freeb.sdk']
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
I am getting this error:
:bintrayUpload FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bintrayUpload'.
> Could not create version '1.1-Final FreeB': HTTP/1.1 400 Bad Request [message:Unable to create version 1.1-Final FreeB at 'ajay-spice/maven/freeb-sdk']
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 22.448 secs
Log file in Debug mode
:app:install
:app:bintrayUpload FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bintrayUpload'.
> Could not create version '1.1-Final FreeB': HTTP/1.1 400 Bad Request [message:Unable to create version 1.1-Final FreeB at 'ajay-spice/maven/freeb-sdk']
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:bintrayUpload'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.api.GradleException: Could not create version '1.1-Final FreeB': HTTP/1.1 400 Bad Request [message:Unable to create version 1.1-Final FreeB at 'ajay-spice/mav
en/freeb-sdk']
at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure6_closure27_closure31.doCall(BintrayUploadTask.groovy:280)
at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:503)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1070)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:434)
at groovyx.net.http.HTTPBuilder.request(HTTPBuilder.java:383)
at groovyx.net.http.HTTPBuilder$request$0.call(Unknown Source)
at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure6.doCall(BintrayUploadTask.groovy:272)
at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure6.doCall(BintrayUploadTask.groovy)
at com.jfrog.bintray.gradle.BintrayUploadTask.bintrayUpload(BintrayUploadTask.groovy:383)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 47 more
BUILD FAILED
Total time: 45.144 secs
The error indicates that you have tried using '1.0-Final FreeB' as the version name which is an invalid version name:
message:Unable to create version 1.1-Final FreeB at 'ajay-spice/maven/freeb-sdk'
A version name must start with a letter or a number and can only contain letters, numbers and the following symbols: .-_:##$~
The build.gradle sources in your question shows a valid version name - '1.1-Final', however this is different from the build.gradle in your Github project which is using the invalid version name.

Resources