Can not deserialize instance of java.sql.Timestamp out of VALUE_NUMBER_FLOAT token

Viewed 3042

I have a RESTful API on Jersey 2.17 with Jackson on JDK8. It is JSON style API. This API accepts a Java object, it has this field:

@JsonProperty("processEndTime")
public Timestamp getRunDate() {
    return runDate;
}

@JsonProperty("processEndTime")
public void setRunDate(Timestamp runDate) {
    this.runDate = runDate;
}

Now when I submit a small number, it works perfectly like this:

"processEndTime" : 1434989360,

But it fails when the number is big one, like this:

"processEndTime" : 1434989360380,

The most weird thing is that I had a Jmeter test case, it sent the exact the same big number, it can pass without any issues. I can verify this number on the server side and confirmed it is correctly passed.

The full error message is:

Can not deserialize instance of java.sql.Timestamp out of VALUE_NUMBER_FLOAT token at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@23117fbd; line: 1, column: 562] (through reference chain: com.abc.api.dto.MyClassA["processEndTime"])

Any suggestions?

1 Answers

I figure out the issue:

I did some converting in the request data:

    JSONObject analysis = new JSONObject(templateAnalysis3); 
    data = analysis.toString(); 

this toString function will convert long number to E format:

    1434989360380 -> 1.43498936038E12

This E format is not supported and caused this failure.

I fixed it by using templateAnalysis3 directly:

    data = templateAnalysis3; 
Related