eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.32k stars 2.08k forks source link

java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonSerializer on 3.6.0 and 3.6.1 #2767

Closed mustafakibar closed 5 years ago

mustafakibar commented 5 years ago

When I run my project I get an error like this: Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonSerializer if I use these versions: 3.6.0 or 3.6.1. But if I return to version "3.6.0.CR1" in my gradle config file then everything works. I try to invalidate cache but it doesn't work.

buildSrc/Config.kt

object Versions {

    val kotlin                  = "1.3.11"
    val vertx                   = "3.6.1"
        val jackson                 = "2.9.7"

}

object Libs {

    val vertx_web               = "io.vertx:vertx-web:${Versions.vertx}"
    val vertx_core              = "io.vertx:vertx-core:${Versions.vertx}"
    val vertx_kotlin            = "io.vertx:vertx-lang-kotlin:${Versions.vertx}"
    val vertx_kotlin_coroutines = "io.vertx:vertx-lang-kotlin-coroutines:${Versions.vertx}"
    val vertx_config            = "io.vertx:vertx-config:${Versions.vertx}"
    val vertx_service_proxy     = "io.vertx:vertx-service-proxy:${Versions.vertx}"
    val vertx_service_discovery = "io.vertx:vertx-service-discovery:${Versions.vertx}"
    val vertx_hazelcast         = "io.vertx:vertx-hazelcast:${Versions.vertx}"
    val vertx_codegen           = "io.vertx:vertx-codegen:${Versions.vertx}"
    val vertx_codegen_kapt      = "io.vertx:vertx-codegen:${Versions.vertx}:processor"

        val jackson_databind        = "com.fasterxml.jackson.core:jackson-databind:${Versions.jackson}"
        val jackson_kotlin          = "com.fasterxml.jackson.module:jackson-module-kotlin:${Versions.jackson}"
}

build.gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    idea
    java
    application
    kotlin("jvm").version(Config.Versions.kotlin)
    kotlin("kapt").version(Config.Versions.kotlin)
}

buildscript {
    dependencies {
        classpath(Config.Plugins.kotlin_gradle)
    }
}

application {
    mainClassName = "App"
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

idea {
    module {
        isDownloadJavadoc = true
        isDownloadSources = true
    }
}

sourceSets {
    getByName("main").resources.srcDirs("conf")
    getByName("main").java.srcDirs("src/main/kotlin", "src/main/java")
    getByName("test").java.srcDirs("src/test/kotlin", "src/main/java")
}

dependencies {
    implementation(project(":common"))
    implementation(kotlin("stdlib"))
    implementation(kotlin("reflect"))

    implementation(Config.Libs.jackson_kotlin)
    implementation(Config.Libs.jackson_databind)

    implementation(Config.Libs.vertx_web)
    implementation(Config.Libs.vertx_core)
    implementation(Config.Libs.vertx_kotlin)
    implementation(Config.Libs.vertx_kotlin_coroutines)
    implementation(Config.Libs.vertx_config)
    implementation(Config.Libs.vertx_service_proxy)
    implementation(Config.Libs.vertx_service_discovery)
    implementation(Config.Libs.vertx_hazelcast)
    compileOnly(Config.Libs.vertx_codegen)
    kapt(Config.Libs.vertx_codegen_kapt)
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs = listOf("-Xjsr305=strict", "-Xjvm-default=enable")
    }
}
vietj commented 5 years ago

that's really weird

vietj commented 5 years ago

there hasn't much changed between versions

vietj commented 5 years ago

did you find out what happens ?

mustafakibar commented 5 years ago

I've tried through version 3.6.2 now but the same problem still continue. I applied the following step by step: Invalidate caches - Delete .gradle folder in %USERNAME% - Delete build and .gradle folder in my project path. As you say that's too weird...

mustafakibar commented 5 years ago

I get the same error in version 3.6.0.CR2

vietj commented 5 years ago

can you make a reproducer ?

mustafakibar commented 5 years ago

I just did the following steps and solved the problem;

  1. Jackson version 2.9.7 to 2.9.8
  2. Vert.x version to 3.6.2
  3. Gradle to 4.10.3
  4. Delete projects build and .gradle(included in user home directory) folders.
  5. Invalidate caches

It's very clear that the problem is not caused by vert.x.