Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
jackson-kotlin dependency causes ClassNotFoundException when finding Jackson modules via service loader #11133
2.0.0.M6: If I use web-starter and activate
If I exclude jackson-kotlin dependency from web-starter, the error does not occur.
See example project attached:
referenced this issue
Nov 24, 2017
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.
Nov 24, 2017
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
@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