Estou fazendo um relatório no Jasper report, quando mando imprimir ocorre o seguinte erro : Invalid page index range: 0 - -1 of 0., alguem sabe corrigir?, segue meu codigo
o erro ocorre nessa lina:
JasperPrintManager.printReport(relatorio, true);
public void imprimir() {
try {
DataTable tabela = (DataTable) Faces.getViewRoot().findComponent("formListagem:tabela");
Map<String, Object> filtros = tabela.getFilters();
String ano = (String) filtros.get("ano");
String mes = (String) filtros.get("mes");
String caminho = Faces.getRealPath("/reports/relacaoHE.jasper");
Map<String, Object> parametros = new HashMap<>();
if (ano == null) {
parametros.put("HE_ANO", "%%");
} else {
parametros.put("HE_ANO", ano);
}
if (mes == null) {
parametros.put("HE_MES", "%%");
} else {
parametros.put("HE_MES", "'%" + mes + "%'");
}
Connection conexao = HibernateUtil.getConexao();
JasperPrint relatorio = JasperFillManager.fillReport(caminho, parametros, conexao);
JasperPrintManager.printReport(relatorio, true);
} catch (JRException erro) {
Messages.addGlobalError("Ocorreu um erro ao tentar gerar o relatório");
erro.printStackTrace();
}
}