-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Registration of jackson-datatype-jsr310
not working in Jackson 2.12.0
#2983
Comments
Some of my assumptions above were wrong, I fixed this by reverting my |
@retrodaredevil so, is this fixed or did you raise this to find out and confirm if this was a bug or not? I do not understand the label "to-evaluate", could you elaborate please? |
@anirudh1122399 "to-evaluate" is automatically added by github issue template -- it's for my use, to help remember issues I have had a decent look at. @retrodaredevil Hmmh. I am not aware of change that should prevent auto-registration, and definitely such change in behavior is not intentional. |
I think the first step here would be to add a test in: https://github.com/FasterXML/jackson-integration-tests/ since that can have cross-module dependencies and operate on jars (java 8 modules' unit tests could otherwise test it but it would run against compiled classes, not jar). I hope to have time to look into this in near future, but if anyone else has time for test reproduction that'd be great. |
After trying this out with a manual test, I do not see an immediate problem with auto-registration: parameter names module seems to located accurately and registered. |
jackson-datatype-jsr310
not working in Jackson 2.12.0
Also failed to reproduce with test case itself, both by registering specific module and by using At this point I am unfortunately unable to reproduce the problem unfortunately and have no idea on what might be causing it. |
If I find the time, I'll try creating a project that creates a jar file with this problem since I can't reproduce it in a simple unit test, either. Like I said, if I use these dependencies:
It does work. But if I use
It does not work. There's also a possibility that this error doesn't come up if you're using Java 8 (I tested with Java 11). It's possible I'll find the time sometime in the next day, or next few days. I don't really have an idea right now. |
@retrodaredevil Thanks. I'll get whatever you can find out. Depending on how easy/difficult it is to do, note that there is also method
|
Ok, so when I first made an empty project and started to add jackson dependencies, I was unable to reproduce this, then I added my mattermost4j dependencies, which also depends on a bunch of other stuff, and that got the same result as my much larger project. Here's the repo: https://github.com/retrodaredevil/jackson-test To reproduce, run You'll notice that it will find the |
For whatever reason, this seems to pass for me, without any changes (just clone the project), using JDK 11.0.8. Output is:
But I think I have an idea of what could be the problem. Looking at test jar I notice that it is simply flattening contents of all
of which only one survives, and order is probably not stable. Why this used to work may be due to JSR310Module having "won" the race? |
Oh that makes sense. Yeah it was weird to me that when the I guess I'll go ahead and close this issue since it's not really a problem with Jackson itself. |
@retrodaredevil Yeah I am not 100% sure how META-INF resource metadata entries should be combined unfortunately. I would think tools need to be able to do that since it is quite common way to include SPI configuration metadata; shade plug-in f.ex should be able to handle it, but I do not really know details. |
For future reference for those using the shadow plugin to build their jars, just add That was an incredibly simple fix. |
@retrodaredevil that makes sense: since the naming of SPI files must be identical, it should make sense that contents can typically be simply concatenated from multiple sources. Thank you for confirming. |
Adding dependency
helps me to solve the issue. |
@bvn13 this worked for me, thanks. |
It works for me with this code: add to POM:
adjust the version as needed :-) then create the ObjectMapper like this in Java:
when it does not load the module automatically, we simply force it to be happy |
Related and possibly helpful for someone With the following in my gradle.build.kts...
...the resulting published POM for my build does not include However, if I define the version it is present in the published POM
|
Describe the bug
On 2.12.0 (2.11.3 doesn't have this bug), findAndRegisterModules does not work for
com.fasterxml.jackson.datatype:jackson-datatype-jsr310
.Version information
2.12.0 on Java 11
To Reproduce
Expected behavior
It should find the module and not throw the error above.
Additional context
I tried putting my code in a JUnit5 test, and it passed perfectly, so this bug isn't something that can be detected by unit tests. I'm using the shadow gradle plugin to compile my code into a fat jar, so something changed between 2.11 and 2.12 that causes this.
Also, adding the line
mapper.registerModule(new JavaTimeModule());
fixes it, so I can guarantee that it exists on my classpath.I wish I had some more info on why this is happening, but seeing how I can't reproduce this in a unit test, I don't really have any idea what the problem is.
The text was updated successfully, but these errors were encountered: