SSL errors in Java can be tricky to debug if the only thing you got is a stacktrace. However, there is a way to get for information out of the JVM. Enabling the JVM property javax.net.debug will print a lot of debug information. E.g. the version of the SSL/TLS protocol used:
The default version of TLS on Java 7 is TLS 1.0. The version can changed by using the https.protocols property:
We will use the Jersey client to send the DTO to the server. The serialization is done using the the Dto using the javax.ws.rs.client.Entity class:
final Entity<DTO> json = Entity.json(dto);
where dto is DTO object.
Jackson will now complain on not knowing how to deserialize the map. Thus, we need to provide a custom key deserializer. Also the Foo key objects will be serialized by calling the toString method, which is rarely what we would like. Thus I will also show how to provide a key serializer.
First the deserializer. In this case it is very simple, and lacks some checks on the integrity of the data. We simply get the text of the JSON element (line 12) and convert it to an integer (line 13). I leave it as an exercise to the reader to implement proper checks.
The serializers must be enabled in order for Jackson to use them. This is done in two steps. First we add proper annotations to the Foo class. Then we register the serializers to the ObjectMapper used by Jersey.
First we add the annotations @JsonSerialize(keyUsing = FooKeySerializer.class) and
@JsonDeserialize(keyUsing = FooKeyDeSerializer.class) to the Foo class (line 1 and 2):