I trying to use the Resteasy CLIENT to call one REST service
In my Service I create with springboot and return one LocalDateTime propert
If I use this depencency
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.8.8</version>
</dependency>
This is my code in my bean:
private LocalDateTime dtPublicacao;
this is the result when I call my service:
dtPublicacao: "2017-04-20T00:00:00"
if I remove this the result:
dtPublicacao: {
hour: 0,
minute: 0,
second: 0,
nano: 0,
dayOfYear: 110,
dayOfWeek: "THURSDAY",
month: "APRIL",
dayOfMonth: 20,
year: 2017,
monthValue: 4,
chronology: {
id: "ISO",
calendarType: "iso8601"
}
}
So in my Client I create the same model and use this to execute the Get
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:8585").path("/edital/");
try{
List<EditalVO> response = target.request().get(new GenericType<List<EditalVO>>(){});
return response;
}catch (NotFoundException e) {
throw new NotFoundException();
}
So, if I put in my client the LocalDateTime I got this error:
Caused by: org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class java.time.LocalDateTime] from JSON String; no single-String constructor/factory method (through reference chain: br.com.lumera.protesto.edital.vo.EditalVO["dtExpiracao"])
to solve I need to change in my client form LocalDateTime to Date and add
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dtPublicacao;
I Already try to add the same dependency in my client, but he register the LocalDateTimeSerializer.class but when I call the REST he dot no go through the serialize method and I got the error again.
Can I RECEIVE AND SEND LocalDateTime from my Restasey CLIENT ??
tks
UPDATE I already try to does this too:
ObjectMapper obj = new ObjectMapper();
obj.registerModule(new JavaTimeModule())
with no success, then I try to in my client :
client.register(obj);
with no success to.. if I debug my app, he enter on methods
public LocalDateTimeSerializer(DateTimeFormatter f) {
super(LocalDateTime.class, f);
}
private LocalDateTimeSerializer(LocalDateTimeSerializer base, Boolean useTimestamp, DateTimeFormatter f) {
super(base, useTimestamp, f);
}
in LocalDateTimeSerializer but don`t enter in serialize method or deserialize