users@jersey.java.net

[Jersey] Routing to a Resource that contains a Date parameter.

From: William Ferguson <william.ferguson_at_xandar.com.au>
Date: Mon, 15 Jul 2013 21:09:14 +1000

I am having trouble getting Jersey to match a resource that contains a
java.util.Date parameter. As soon as I remove the Date field from the input
the Resource is found.

I thought at first that it was because my deserialization config (I'm using
Jackson-2.2.2), but after several attempts, and after defining my own
serialization/deserialization I realised that the deserialization isn't
even being called before the Resource fails to match.

So I'm wondering what I need to do to get Jersey to match against a Date
parameter?

Input:
/timing/createJsonMeet
{
        "meetDate": 1370786400000,
        "description": "My new meet thingy 1",
        "meetFileName": "Some meet file"
  }

    @POST
    @Path("/createJsonMeet")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Meet createMeetJson(Meet meet) { // Where Meet is a simple POJO
that contains a Date field called meetDate
    ...
    }

NB I tried all kinds of date formats for meetDate but have left it at
millis since epoch as this is what Jackson also serializes to.

Note also that when I constructed and configured an ObjectMapperProvider,
it's #getContext method was only being called when serializing outputs into
the Response, never for deserializing the Request.

Jersey-2.0
Jackson-2.2.20
Jetty-9.0.4.v20130625

William