I have a Java application developed using the Quarkus framework. It hits the external API using the RestClient which works fine locally, however when I create the containerized native image and deploy it to Kubernetes it gives the below error message:
Cannot construct instance of `com.abc.xyz.ZohoLeaveDto`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
at [Source: (StringReader); line: 1, column: 3] (through reference chain: java.util.ArrayList[0])**
@Override
public List<ZohoLeaveDto> getLeaves(String token, Instant lastModifiedTime, int index, int limit) {
log.infov(
"Request to get leaves with last modified time: {0}, milli: {1}",
lastModifiedTime,
lastModifiedTime.toEpochMilli());
try {
token = StringUtils.isBlank(token) ? getAccessToken() : token;
String apiResponse = zohoRestClient.getLeaves(token, index, limit,
lastModifiedTime.toEpochMilli());
log.infov("leave api response: {0}", apiResponse);
objectMapper.registerModules(new ParanamerModule(), new ParameterNamesModule());
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode responseJson = objectMapper.readValue(apiResponse, JsonNode.class);
if (responseJson.get(0).get("errorcode") != null) {
log.errorv("Unable to get leaves from zoho due to :{0}", responseJson);
return Collections.emptyList();
} else {
List<ZohoLeaveDto> leaves = objectMapper.readValue(apiResponse,
new TypeReference<List<ZohoLeaveDto>>() {
});
log.infov("{0} leave records has been fetched successfully", leaves.size());
return leaves;
}
} catch (Exception e) {
log.errorv("error in fetching leaves from zoho: {0}", e.getMessage());
return Collections.emptyList();
}
}
ZohoLeaveDto.java
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@RegisterForReflection
public class ZohoLeaveDto {
@Schema(example = "4106900")
private String recordId;
@JsonAlias("Employee ID")
@Schema(example = "Aleo Kirb S2")
private String employeeId;
...
}