GithubHelp home page GithubHelp logo

`NoSuchMethodError` for `com.fasterxml.jackson.module.kotlin.jacksonObjectMapper` after upgrading to 2.17.0 about jackson-module-kotlin HOT 12 CLOSED

erdi avatar erdi commented on July 17, 2024 1
`NoSuchMethodError` for `com.fasterxml.jackson.module.kotlin.jacksonObjectMapper` after upgrading to 2.17.0

from jackson-module-kotlin.

Comments (12)

k163377 avatar k163377 commented on July 17, 2024 1

Please attach reproducible code.

Also, please check the com.fasterxml.jackson.module.kotlin.PackageVersion at runtime.
As mentioned above, the version of KotlinModule may have been overwritten at runtime.
If not, you should get 2.17.x.

from jackson-module-kotlin.

Dogacel avatar Dogacel commented on July 17, 2024 1

Sorry I can't because it is company code.

However, I figured it out. Turns out my dependency tree was different in runtime and compile time somehow. The reason why I never realized this is that spring gradle plugin enforces a certain version of kotlin and it basically overrides everything that you specify in dependencies block. The only solution is to add the following,

configurations.all {
  resolutionStrategy.eachDependency { details ->
    if (details.requested.group.startsWith("com.fasterxml.jackson")) {
      details.useVersion("2.17.0")
    }
  }
}

from jackson-module-kotlin.

k163377 avatar k163377 commented on July 17, 2024 1

@be-hase
I was mistaken on this issue.
I assumed that Kotlin would prioritise the use of non-default functions, but unfortunately this is not the case.
https://youtrack.jetbrains.com/issue/KT-17300

As you say, this was unintentionally breaking compatibility.

I will look into fixing this over the weekend if possible.

from jackson-module-kotlin.

be-hase avatar be-hase commented on July 17, 2024 1

Thanks.

I did a little research and it doesn't look like there is a good way to do it...
The only way might be to write the overload by hand.

https://medium.com/@yi.lu_55329/is-kotlin-default-arguments-a-solution-of-binary-backward-compatibility-374d2c9214d4

from jackson-module-kotlin.

k163377 avatar k163377 commented on July 17, 2024 1

This will be fixed in the next release.

from jackson-module-kotlin.

erdi avatar erdi commented on July 17, 2024

FYI, ObjectMapper().registerModule(kotlinModule()) where kotlinModule is imported as com.fasterxml.jackson.module.kotlin.kotlinModule seems to work. kotlinModule does not carry @JvmOverloads so maybe that's related?

from jackson-module-kotlin.

k163377 avatar k163377 commented on July 17, 2024

From the error message, it looks like you are running code compiled with 2.17 on a version less than 2.17.
Can you confirm which version is being used at runtime?
Or more information is needed.

from jackson-module-kotlin.

Dogacel avatar Dogacel commented on July 17, 2024

I am having the same issue, I am almost certain our runtime versions are up-to-date and 2.17.

from jackson-module-kotlin.

k163377 avatar k163377 commented on July 17, 2024

Thanks for the verification.
Anyway, it seems that there is no problem with jackson-module-kotlin, so this issue is closed.

from jackson-module-kotlin.

cowtowncoder avatar cowtowncoder commented on July 17, 2024

And fwtw, Jackson 2.17.1 was just released today. Probably won't change behavior here but just in case, upgrade strongly recommended (from 2.17.0).

from jackson-module-kotlin.

be-hase avatar be-hase commented on July 17, 2024

@k163377
Did jackson intentionally make the compatibility loss from version 2.17?

Spring boot users often tend to use BOM to fix version.
(using dependency-management-plugin, gradle constraints, etc...)

The latest spring boot BOM is still jackson 2.15.4, so I think there are many cases in the JVM community where code compiled with 2.17.x is used in older jackson environments.

If there is a reason for the loss of compatibility, we should accept, but if the loss of compatibility is unintentional?

The reproduction code is available here.
https://github.com/be-hase/jackson-issue-202405

from jackson-module-kotlin.

be-hase avatar be-hase commented on July 17, 2024

thanks :)

from jackson-module-kotlin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.