Drowizard configuration fails with jackson 2.6.3

Skip to first unread message

Davi Reis

Nov 28, 2015, 4:16:09 PM11/28/15
to dropwizard-dev

I am using jackson 2.6.3 with dropwizard, and configuration parsing fails because jackson does not find the @JsonCreator deserializers for Duration and Size from io.dropwizard.util, resulting in the following error message:

* Failed to parse configuration; Could not find creator property with name 'duration' (in class io.dropwizard.util.Duration)
 at [Source: N/A; line: -1, column: -1]

Everything works fine with jackson 2.5.3 and older versions. I added a custom deserializer to my code that delegates to the @JsonCreator factory methods and things worked fine. I wonder if the problem is the lack of @JsonProperty in the parameters, as hinted in the question below?

I will be happy to send a patch if the problem and solution description look correct to you.

Filipe Cristóvão

Dec 2, 2015, 3:46:33 AM12/2/15
to dropwizard-dev
Hey there,

I had the exact same issue, but I'm not sure that it's Dropwizard's fault.

  • Single-argument constructor/factory method without JsonProperty annotation for the argument: if so, this is so-called "delegate creator", in which case Jackson first binds JSON into type of the argument, and then calls creator
The code in the Duration and Size classes corresponds to these.
This might actually be a bug in jackson, from what I can see.

Jochen Schalanda

Dec 2, 2015, 6:06:55 AM12/2/15
to dropwiz...@googlegroups.com
Hi Filipe,

I can't reproduce the problem you're describing. Serializing and deserializing Duration and Size instances from JSON via Jackson is working as intended (see https://github.com/dropwizard/dropwizard/commit/6646a89b6298e2e010656fd5bbc426f5140d4351 for the relevant unit test).

Check your project for incompatible versions of Jackson artifacts, e. g. using `mvn dependency:tree` or the Maven Enforcer plugin.


You received this message because you are subscribed to the Google Groups "dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jairam Chandar

Mar 9, 2016, 12:34:27 PM3/9/16
to dropwizard-dev
Hi Davi,

Did you manage to sort the problem? I'm facing the same issue and I've checked to make sure I have all jackson libraries at 2.6.3. 

- Jairam

Filipe Cristóvão

Mar 9, 2016, 12:41:43 PM3/9/16
to dropwizard-dev
Hello Jairam,

  I'm not sure if you're having the same issue as I did.
  In my case I was using Scala with Dropwizard. 
  For that I was adding the "DefaultScalaModule" from https://github.com/FasterXML/jackson-module-scala
  Turns our, there is a "ParanamerAnnotationIntrospector" being mixed in in that module that conflicted somehow with other dependencies.
  In our case, we build a "fixed" version that didn't include that AnnotationIntrospector (but leaving the ScalaAnnotationIntrospector) and things started working.

Hope this helps.

Jason Fine

Mar 21, 2016, 10:23:26 AM3/21/16
to dropwizard-dev
Thanks Filipe,

Your solution solved my problem. If you have more information on how this should be fixed correctly perhaps you can share it with us / with jackson-scala-module devs so the next versions will be fixed?

Pierre Vincent

Apr 5, 2016, 7:42:26 AM4/5/16
to dropwizard-dev
Thanks a lot for your post Filipe, that is working perfectly with your suggestion.

I've posted a quick article with a code sample to work around the issue: http://techblog.newsweaver.com/config-parsing-issue-dropwizard-0-9-scala

Francois Laroche

Apr 27, 2016, 4:15:59 AM4/27/16
to dropwizard-dev
Hi all,

I faced the same issue, but I use scala 2.12-M4.
In this version of the scala module, some of the traits are not visible, so I couldn't build a fixed version as said.

This led me to find another solution :

override def initialize(bootstrap: Bootstrap[MyConfiguration]): Unit = {
val objectMapper: ObjectMapper = bootstrap.getObjectMapper
objectMapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(ScalaAnnotationIntrospector, new JacksonAnnotationIntrospector()))

This did the trick for me.


Reply all
Reply to author
0 new messages