-
Notifications
You must be signed in to change notification settings - Fork 41.1k
jackson-kotlin dependency causes ClassNotFoundException when finding Jackson modules via service loader #11133
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
Comments
Indeed, Jackson does not perform defensive check about the presence of Kotlin in the classpath before registering |
@gbrehmer Thanks for opening a new issue for this. Out of interest, what prompted you to activate @sdeleuze Please do open a Jackson pull request, but I think there's a chance that it'll be declined. Our starter's "breaking" |
After a deeper look, the It is true that But that will raise again the question about how we could handle the creation of Kotlin web project on start.spring.io that works out of the box. I am not sure yet about how to handle that. |
Looking at the code for For this to work, @sdeleuze If you find a way to get this to work, please do let us know. I can only see two options at the moment:
1 doesn't really feel like a reasonable option as people who shouldn't have to care about Kotlin and its Jackson module now have to deal with it. I fear that the only realistic option here is 2. |
Yeah, I also think that the only realistic option is to remove I don't want to do again all the discussion we had previously on that topic, but I think there is a reasonable solution: acknowledge that Kotlin is a language but also a technology that deserves its own starter. We currently add directly Instead of adding A |
@sdeleuze Thanks for the suggestion. I'm not keen on the idea of having Setting up a Spring Boot project to use Kotlin should, ideally, look the same as setting up any other project in terms of the core dependencies that you need to declare and the build plugins that need to be configured. Spring Initializr takes care of that boilerplate, but what it produces is hopefully idiomatic and commonly-used. I think that's important. Starting a Kotlin app that has Jackson on the class path but does not have
There are no fewer than 8 lines telling me that I need to add the jackson-module-kotlin dependency, each similar to the following:
While this isn't ideal, I think it's preferable to introducing a language-specific starter. I also think that this is good enough for Spring Boot 2.0 given the problems that this issue has identified with our preferred solution/workaround. In all likelihood, the ideal solution to this problem belongs in Spring Initializr. When time is available, I can foresee it having more sophisticated support for automatically adding a dependency, such as |
|
Technically it could be possible but based on the various feedback we had, I now tend to think that adding |
just broke my little app when compiling |
2.0.0.M6: If I use web-starter and activate
findModulesViaServiceLoader
onJackson2ObjectMapperBuilder
the application raises anjava.lang.ClassNotFoundException: kotlin.jvm.internal.DefaultConstructorMarker
on startup.If I exclude jackson-kotlin dependency from web-starter, the error does not occur.
See example project attached:
sample.zip
The text was updated successfully, but these errors were encountered: