Estou com problemas para chamar relatório aplicação JSF. Não busca dados no NetBeans 8.1 não reconhece arquivo gerado Jaspersoft. Não encontro plugin para esta versão.
RelatorioPedidosEmitidos.xhtml
<ui:define name="titulo">Relatório de pedidos emitidos</ui:define>
<ui:define name="corpo">
<h:form id="frm">
<h1>Relatório de pedidos emitidos</h1>
<p:messages autoUpdate="true" closable="true" />
<p:toolbar style="margin-top: 20px">
<p:toolbarGroup>
<p:commandButton value="Emitir" action="#{relatorioPedidosEmitidosBean.emitir}"
ajax="true" />
</p:toolbarGroup>
</p:toolbar>
<p:panelGrid columns="2" id="painel" style="width: 100%; margin-top: 20px"
columnClasses="rotulo, campo">
<p:outputLabel value="Data de criação" />
<h:panelGroup>
<p:calendar value="#{relatorioPedidosEmitidosBean.dataInicio}" label="Data inicial"
pattern="dd/MM/yyyy" size="8" />
<p:spacer width="8" />
<h:outputText value="a" />
<p:spacer width="8" />
<p:calendar value="#{relatorioPedidosEmitidosBean.dataFim}" label="Data final"
pattern="dd/MM/yyyy" size="8" />
</h:panelGroup>
</p:panelGrid>
</h:form>
</ui:define>
RelatorioPedidosEmitidosBean.java
@Named
@RequestScoped
public class RelatorioPedidosEmitidosBean implements Serializable {
private static final long serialVersionUID = 0L;
private Date dataInicio;
private Date dataFim;
@Inject
private FacesContext facesContext;
@Inject
private HttpServletResponse response;
@Inject
private EntityManager manager;
public void emitir() {
Map<String, Object> parametros = new HashMap<>();
parametros.put("data_inicio", this.dataInicio);
parametros.put("data_fim", this.dataFim);
ExecutorRelatorio executor = new ExecutorRelatorio("/relatorios/relatorios_pedidos_vendas.jasper",
this.response, parametros, "Pedidos emitidos.pdf");
Session session = manager.unwrap(Session.class);
session.doWork(executor);
if (executor.isRelatorioGerado()) {
facesContext.responseComplete();
} else {
FacesUtil.addErrorMessage("A execução do relatório não retornou dados.");
}
}
@NotNull
public Date getDataInicio() {
return dataInicio;
}
public void setDataInicio(Date dataInicio) {
this.dataInicio = dataInicio;
}
@NotNull
public Date getDataFim() {
return dataFim;
}
public void setDataFim(Date dataFim) {
this.dataFim = dataFim;
}
}
ExecutorRelatorio.java
public class ExecutorRelatorio implements Work {
private String caminhoRelatorio;
private HttpServletResponse response;
private Map<String, Object> parametros;
private String nomeArquivoSaida;
private boolean relatorioGerado;
public ExecutorRelatorio(String caminhoRelatorio,
HttpServletResponse response, Map<String, Object> parametros,
String nomeArquivoSaida) {
this.caminhoRelatorio = caminhoRelatorio;
this.response = response;
this.parametros = parametros;
this.nomeArquivoSaida = nomeArquivoSaida;
this.parametros.put(JRParameter.REPORT_LOCALE, new Locale("pt", "BR"));
}
@Override
public void execute(Connection connection) throws SQLException {
try {
InputStream relatorioStream = this.getClass().getResourceAsStream(this.caminhoRelatorio);
JasperPrint print = JasperFillManager.fillReport(relatorioStream, this.parametros, connection);
this.relatorioGerado = print.getPages().size() > 0;
if (this.relatorioGerado) {
Exporter<ExporterInput, PdfReportConfiguration, PdfExporterConfiguration,
OutputStreamExporterOutput> exportador = new JRPdfExporter();
exportador.setExporterInput(new SimpleExporterInput(print));
exportador.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
JasperExportManager.exportReportToPdfStream(print, response.getOutputStream());
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=\""
+ this.nomeArquivoSaida + "\"");
exportador.exportReport();
}
} catch (Exception e) {
throw new SQLException("Erro ao executar relatório " + this.caminhoRelatorio, e);
}
}
public boolean isRelatorioGerado() {
return relatorioGerado;
}
log quando tento emitir relatorio;
MonitorFilter::WARNING: the monitor filter must be the first filter in the chain. MonitorFilter::WARNING: the monitor filter must be the first filter in the chain. Hibernate: select usuario0_.id as id1_7_, usuario0_.email as email2_7_, usuario0_.nome as nome3_7_, usuario0_.senha as senha4_7_ from usuario usuario0_ where lower(usuario0_.email)=? Hibernate: select grupos0_.usuario_id as usuario_1_8_0_, grupos0_.grupo_id as grupo_id2_8_0_, grupo1_.id as id1_3_1_, grupo1_.descricao as descrica2_3_1_, grupo1_.nome as nome3_3_1_ from usuario_grupo grupos0_ inner join grupo grupo1_ on grupos0_.grupo_id=grupo1_.id where grupos0_.usuario_id=? MonitorFilter::WARNING: the monitor filter must be the first filter in the chain. Hibernate: select date(data_criacao) as data, sum(this_.valor_total) as y1_ from pedido this_ where this_.data_criacao>=? group by date(data_criacao) Hibernate: select date(data_criacao) as data, sum(this_.valor_total) as y1_ from pedido this_ where this_.data_criacao>=? and this_.vendedor_id=? group by date(data_criacao) MonitorFilter::WARNING: the monitor filter must be the first filter in the chain. MonitorFilter::WARNING: the monitor filter must be the first filter in the chain.