I am facing issues while returning response from "/index" method. As far as in grails i have handled this error using marshaller but marshaller cannot be used in micronaut : See Error logs
{
"message": "Internal Server Error: Error encoding object [{dashboards=[com.ef.Domains.Dashboard : 1, com.ef.Domains.Dashboard : 2, com.ef.Domains.Dashboard : 3], status=OK}] to JSON: failed to lazily initialize a collection of role: com.ef.Domains.Dashboard.dashboardGadgets, could not initialize proxy - no Session (through reference chain: java.util.LinkedHashMap[\"dashboards\"]->java.util.ArrayList[0]->com.ef.Domains.Dashboard[\"dashboardGadgets\"])"
}
I have tried the followings in my code here:
@Get("/index")
@Transactional
@JsonIgnore
def index(HttpParameters P){
def resultSet = [:]
try {
def dashboardsList = Dashboard.list()
ObjectMapper mapper = new ObjectMapper();
// Serialization from Object to JSON
dashboardsList =
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(dashboardsList);
resultSet.put("dashboards", dashboardsList);
resultSet.put("status", HttpStatus.OK);
} catch (Exception ex) {
resultSet.put("status", HttpStatus.INTERNAL_SERVER_ERROR);
log.info("Some Error Occurred while Fetching List of Dashboards. See Error Logs for More Details.");
log.error("Occurred while Fetching List of Dashboards", ex);
}
return resultSet
}
I am facing issues while returning response from "/index" method. As far as in grails i have handled this error using marshaller but marshaller cannot be used in micronaut : See Error logs
I have tried the followings in my code here:
Any help will be appreciated