-2
I am trying to perform data export from Log to Excel only it is presenting me the following error:
2019-03-18 10:16:16.022 ERROR 252 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/mv-fatur] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
The implementation is being done as follows:
Logacessoutil.java
@Override
@SuppressWarnings("unchecked")
public List<LogAcessoDTO> getLogAcessoExcel(String cdCliente) {
LocalDateTime agora = LocalDateTime.now();
DateTimeFormatter formatterData = DateTimeFormatter.ofPattern("dd/MM/uuuu");
String dataFormatada = formatterData.format(agora);
StringBuilder sql = new StringBuilder();
sql.append("select * from cli");
List<LogAcessoDTO> returnQuery = em.createNativeQuery(sql.toString(), "LogAcessoDTOMapping").getResultList();
return (List<LogAcessoDTO>) returnQuery;
}
Globalcontroller.java
@Autowired
private LogAcessoUtil logAcessoUtil;
@Autowired
private ExportFileService<LogAcessoDTO> exportFileServiceDetalhe;
@GetMapping("/getlogacesso/excel")
public ResponseEntity<List<LogAcessoDTO>> getLogAcessoExcel(@RequestParam String cdCliente, HttpServletResponse response) {
try {
List<LogAcessoDTO> dtos = logAcessoUtil.getLogAcessoExcel(cdCliente);
exportFileServiceDetalhe.exportExcelFile(dtos, response, "LogAcesso", "", "Cod. Cliente: " + cdCliente.toString());
return new ResponseEntity<>(HttpStatus.OK);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | IOException ex) {
log.error(ex.toString());
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Ikaro, you just posted a line of stacktrace, would you kindly post the full stacktrace? The more details about the problem the better, and the complete stack and one of the most important points to find the problem.
– nullptr
Please also post the other classes involved, such as the
LogAcessoUtil
which is probably presenting the problem. And also the way it is by injecting the properties– nullptr