Netbeans Does Not Recognize File . Java

Asked

Viewed 203 times

0

I am having trouble calling report JSF application. Do not search for data in Netbeans 8.1 does not recognize Jaspersoft generated file. I cannot find plugin for this version.

Request reports issued.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>

Reportarypedidosemitdosbean.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;
}

}

Executaorrelatorio.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 when I try to issue report;

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_.password as senha4_7_ from username usuario0_ Where Lower(usuario0_.email)=? Hibernate: select groups0_.usuario_id as usuario_1_8_0_, groups0_.grupo_id as group_id2_8_0_, group1_.id as id1_3_1_, group1_.Description as descrica2_3_1_, group1_.name thename3_3_1_ from usuario_group group0_InnerJoin group group1_on group0_.group_id=group1_.id Where group0_.user_id=? Monitorfilter::WARNING: the monitor filter must be the first filter in the chain. Hibernate: select date(creation date) as data, sum(this_.valu_total) as y1_from request this_Where this_.data_creation>=? group by date(creation data_creation) 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(creation date) 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.

Image package inserir a descrição da imagem aqui

  • Be more specific... Your question is very confusing.

  • I generated a report in Jaspersoft I copied the same to the application folder in netbeans, only it has unrecognized file, because I don’t have ireport plugin installed, but this plugin only has version for netbeans 7.4. would have some problem installing this version in my netbeans 8.1. or is there another way to resolve this detail?

  • downloaded installed netbeans is recognizing but in mine when trying to issue reports passes exception finds no data, and there is data to be loaded,

  • Put snippets of codes. images, etc, so we can better help you!

  • is there already thank you!

  • Could put an image of your maximized package explorer?

  • put Nayron,

Show 2 more comments

1 answer

0


To generate the report with Jasperreport you will need the following libraries:

  • Commons-beanutils
  • Commons-Collections
  • Commons-digester
  • Commons-logging
  • groovy-all
  • iText poi
  • jasperreports

Make sure you have all of them added and configured to your project, use Ireport or Jasperstudio to develop the report design, noting that the first one is only compatible with Java 7. In such a way that there will be no dependency on Netbeans, everything will happen independently.

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.