当前位置: 首页 > 面试题库 >

从bean检索字段值时出错

满博
2023-03-14
问题内容

我在尝试使用 JasperReports 从Java生成报告时遇到问题,但出现错误。

public void init() throws JRException {
    list= ef.comisionReporte();
    JRBeanCollectionDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(list);
    String reportPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("report2.jasper");

    jasperPrint = JasperFillManager.fillReport(reportPath, new HashMap(), beanCollectionDataSource);
}

public void PDF() throws JRException, IOException {
    init();
    HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
    httpServletResponse.addHeader("Content-disposition", "attachment; filename=report.pdf");
    ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
    JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
    FacesContext.getCurrentInstance().responseComplete();
}

堆栈跟踪:

GRAVE: Se ha recibido 'net.sf.jasperreports.engine.JRException' al invocar la escucha de acción '#{liquidarComisionReporte.PDF()}' para el componente 'pdfreporte'
GRAVE: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : nombretienda
    at net.sf.jasperreports.engine.data.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:100)
    at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:895)
    at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:860)
    at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:837)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1434)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:126)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:765)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:540)
    at com.itsolutions.nomina.vista.liquidarComision.liquidarComisionReporte.init(liquidarComisionReporte.java:100)
    at com.itsolutions.nomina.vista.liquidarComision.liquidarComisionReporte.PDF(liquidarComisionReporte.java:119)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737)
    at javax.el.BeanELResolver.invoke(BeanELResolver.java:467)
    at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:254)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:228)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoSuchMethodException: Unknown property 'nombretienda' on class 'class [Ljava.lang.Object;'
    at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1322)
    at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:770)
    at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:846)
    at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
    at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:111)
    ... 61 more

问题答案:

你的豆长什么样?导致此错误的一个可能原因是您没有该字段的吸气剂。吸气剂必须遵守Java标准格式,因此您认为我愿意getNombretienda()。吸气剂也必须是public



 类似资料:
  • 在WooCommerce结账页面上,我添加了一个客户必须输入才能结账的额外字段。 我想在woocommerce\u cart\u calculate\u fees操作挂钩中访问此字段的值。 通过使用woocommerce,我尝试了几种方法-

  • 问题内容: 我正在寻找一种将URL片段(#)中的值注入到bean(JSF)中的方法,就像注入查询参数值一样。我正在使用Ben Alman的可标记jQuery插件(http://benalman.com/projects/jquery-bbq- plugin/ )创建URL片段。我希望从prettyFaces获得的自定义正则表达式模式可以解决我的问题,但是直到现在我还是没有成功。 (http://o

  • 我正在尝试使用stream builder检索数组“类”,如下图所示。我尝试使用未来构建器进行相同的尝试,但没有从之前提出的问题中找到正确的解决方案。如何检索类列表并在listview中显示? 当我将鼠标悬停在['fields']上时,错误出现在< code > snapshot . data[' fields '][' class '][position]处,显示: 参数类型“String”不能

  • 我有个问题。我正在使用从我的Android应用程序调用我的api。一切正常,但当我收到一个空字段时,我会出现以下错误: 应为BEGIN_对象,但在第1行第8599列path$处为BEGIN_数组。元。标页码链接 问题是与链接字段有时是不是空 但当它为空时,就会出现错误。我的问题是,当链接字段为空时,我该如何处理? 这是我的全部回应: 这是我的POJO课程:

  • 我要查找的值是 下面的HTML代码。

  • 本文向大家介绍sharepoint清单。从网站检索列表字段,包括了sharepoint清单。从网站检索列表字段的使用技巧和注意事项,需要的朋友参考一下 示例