Jasper Reports - Error fetching bean value

2

I've been looking for 3 days now and can not solve this problem. Let's explain: I'm creating a report in jaspersoft studio and linking to my database, in the preview of my report (within the jaspersoft software) everything is working perfectly. As can be seen in the following images:

Ionlyhave3fieldsinmyreport:name,measure,andneighborhood.

Withinmysoftware,whenIcallthereportitgivestwodifferenterrors,Icannotfigureoutwhattodo.

Followmysourcecodesforbetterviewing:

ReportUtils-Classthatwillgeneratethereport

publicstaticvoidexecutarRelatorio(StringcaminhoRelatorio,Map<String,Object>parametros,StringnomeRelatorio,JRBeanCollectionDataSourcefonteDados)throwsIOException{FacesContextcontext=FacesContext.getCurrentInstance();HttpServletResponseresponse=(HttpServletResponse)context.getExternalContext().getResponse();//pegarcaminhodorelatoriojasperInputStreamreportStream=context.getExternalContext().getResourceAsStream(caminhoRelatorio);response.setContentType("application/pdf");

    try {
        ServletOutputStream servletOutput = null;
        try {
            servletOutput = response.getOutputStream();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (parametros == null) {
            parametros = new HashMap<String, Object>();
        }

        JasperRunManager.runReportToPdfStream(reportStream, servletOutput, parametros, fonteDados);

        try {
            servletOutput.flush();
            servletOutput.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (JRException e) {
        e.printStackTrace();
    } finally {
        context.getResponseComplete();
    }
}

My Managed Bean

public void emitir() {
    relatorios = dao.listarTodos();
    JRBeanCollectionDataSource fonteDados = new JRBeanCollectionDataSource(relatorios); // aqui está vindo completo meu JRbeanCollection está trazendo todos os dados que preciso
    FacesContext context = FacesContext.getCurrentInstance();
    ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();


    try {
        RelatorioUtil.executarRelatorio("/relatorios/RelatorioMedidaCautelar.jasper", null, "Relatorio", fonteDados);
    } catch (IOException ex) {
        Logger.getLogger(MBRelatorio.class.getName()).log(Level.SEVERE, null, ex);
    }

}

This is the error it generates

  

net.sf.jasperreports.engine.JRException: Error retrieving field value from bean: at net.sf.jasperreports.engine.JRAbstractBeanDataSource.getBeanProperty (JRAbstractBeanDataSource.java:123) at net.sf.jasperreports.engine. data.JRAbstractBeanDataSource.getFieldValue (JRAbstractBeanDataSource.java:96) at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue (JRBeanCollectionDataSource.java:109) at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues (JRFillDataset. java: 1358) at net.sf.jasperreports.engine.fill.JRFillDataset.next (JRFillDataset.java:1259) at net.sf.jasperreports.engine.fill.JRFillDataset.next (JRFillDataset.java:1235) at net.sf .jasperreports.engine.fill.JRBaseFiller.next (JRBaseFiller.java:1614) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport (JRVerticalFiller.java:150) at net.sf.jasperreports.engine.fill.JRBaseFiller .fill (JRBaseFiller.java:963) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill (JRBaseFiller.java:892) at net.sf .jasperreports.engine.fill.JRFiller.fill (JRFiller.java:114) at net.sf.jasperreports.engine.JasperFillManager.fill (JasperFillManager.java:668) at net.sf.jasperreports.engine.JasperFillManager.fill (JasperFillManager .java: 649) at net.sf.jasperreports.engine.JasperRunManager.runToPdfStream (JasperRunManager.java:437) at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfStream (JasperRunManager.java:858) at br.com.agilles. (.Resources.Utilities) .Resources.Utils.RecordingUtil.ExecuteReport (ReportUtil.java:57) at br.com.agilles.medidas.beans.MBRelatorio.emitir (MBRelatorio.java:58) Caused by: java.lang.NoSuchMethodException: Unknown property '' on class 'class br.agilles.measures.models.report' at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty (PropertyUtilsBean.java:1277) at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty (PropertyUtilsBean.java: 808) at org.apache.commons.beanutils.PropertyUtilsBean.getProperty (PropertyUtilsBean.java:884) at org.apache.commons.beanu tils.PropertyUtils.getProperty (PropertyUtils.java:464) at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty (JRAbstractBeanDataSource.java:111) ... 57 more

Important to say: My JRBeanCollectionDataSource is coming fully populated with all the correct data: name, measurement and neighborhood.

Can anyone help me?

    
asked by anonymous 29.10.2015 / 17:35

1 answer

1

I have a problem with JRXML, when it takes the fields through the query, in the xml it generates a field description, and in this field description it is blank, and it is in it that I need to put the names of my attributes of my application.

    
03.11.2015 / 12:19