Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodError: No direct method <init>(IZZILkotlin/jvm/internal/DefaultConstructorMarker;)V in class Lcom/fasterxml/jackson/module/kotlin/KotlinModule; or its super classes (declaration of 'com.fasterxml.jackson.module.kotlin.KotlinModule #282

Closed
Praween opened this issue Dec 19, 2019 · 8 comments

Comments

@Praween
Copy link

Praween commented Dec 19, 2019

Hi,

Android Studio : 3.5.3

One of my project library is using, registerModules(KotlinModule()) as

private var objectMapper = ObjectMapper().apply {
            registerModules(KotlinModule())
            disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            setSerializationInclusion(JsonInclude.Include.NON_NULL)
        }

using latest version of jackson-kotlin-module -2.10.1 from maven repository

After addition of above piece, my application crash on launch spitting in logcat as ,

Process: com.potreromed.accurynmonitor, PID: 1859
java.lang.NoSuchMethodError: No direct method (IZZILkotlin/jvm/internal/DefaultConstructorMarker;)V in class Lcom/fasterxml/jackson/module/kotlin/KotlinModule; or its super classes (declaration of 'com.fasterxml.jackson.module.kotlin.KotlinModule' appears in /data/app/com.potreromed.accurynmonitor-2/base.apk)
at com.potreromed.phg.client.PhgClient$Builder.(PhgClient.kt:63)
at com.potreromed.accurynmonitor.data.net.AcmMqtt.getMqttClient(AcmMqtt.kt:66)
at com.potreromed.accurynmonitor.AccurynApplication$initPhgClient$1.run(AccurynApplication.kt:119)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

function added in the library for json support,

buildscript {
    ext.kotlin_version = '1.3.61'
    ext.android_plugin_version = '3.5.3'
    ext.jacoco_version = '0.8.1'
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://repo.eclipse.org/content/repositories/paho-snapshots/" }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$android_plugin_version"
        classpath "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
     }
}
allprojects {
    repositories {
        google()
        jcenter()
        // Set up a repository which looks for dependencies in the "libs" folder
        flatDir { dirs 'libs' }
    }
}

Tried googling, cleaned cache, rebuilding .... checking gradle app dependencies for the library conflict. So far nothing worked for me.

Regards,
Praween

@erika33
Copy link

erika33 commented Dec 20, 2019

[email protected]

@frost13it
Copy link
Contributor

Duplicate of #279

@cowtowncoder
Copy link
Member

Dup as per above: fix will be in 2.10.2 thanks to patch by @frost13it

@Yochyo
Copy link

Yochyo commented Nov 16, 2020

Had the same problem with 2.11.3. Switching to version 2.10.2 fixed the issue.

@nonproto
Copy link

nonproto commented Mar 3, 2021

Had the same issue with 2.12.1 with a kotlin library that was being imported into a java spring boot app. Downgrading to 2.10.2 fixed it

@patrykkrawczyk
Copy link

patrykkrawczyk commented Aug 17, 2021

This should be reopened as this is still a problem in 2.12.3 and 2.12.4 @cowtowncoder
For anyone wanting to use a new version, try changing:

registerModule(KotlinModule()) // this
registerKotlinModule()         // to this

@dinomite
Copy link
Member

@patrykkrawczyk I think you'll find that your application has multiple Jackson versions that are being hoisted by the build system. Look at the dependencies task in Gradle or dependency:tree in Maven.

This isn't a bug in jackson-module-kotlin 2.12.3 or 2.12.4, but rather an API change triggered in j-m-k 2.12, so a library built against a version prior to 2.12 but run with 2.12 or greater won't be able to find the method that it was built against.

@strowk
Copy link

strowk commented Mar 21, 2022

@dinomite , could you point at exactly what was the breaking change in that module?
I cannot see anything in https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.12 . Is there any migration guide?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants