atsu Posted August 12, 2010 Share Posted August 12, 2010 I'm trying to call a jasper report in a java application but it gives me the following error.I am using netbeans ide 6.9and ireport 3.7.3Below are the errors that I get when I run the code[EL Info]: 2010-08-12 09:06:49.707--ServerSession(12759798)--EclipseLink, version: Eclipse Persistence Services - 2.0.2.v20100323-r6872[EL Info]: 2010-08-12 09:06:51.111--ServerSession(12759798)--file:/C:/Users/masterelose/Desktop/current/FHMS/src/_FHMSPU login successfulData source : net.sf.jasperreports.engine.data.JRBeanCollectionDataSource@b05236net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : squid_quantity 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:823) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:787) at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1478) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:125) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:942) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:860) 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:605) at com.fhms.reporting.ReportManager.showReport(ReportManager.java:25) at com.fhms.ui.FHMSMainWindow.reportViewerLinkActionPerformed(FHMSMainWindow.java:355) at com.fhms.ui.FHMSMainWindow.access$400(FHMSMainWindow.java:22) at com.fhms.ui.FHMSMainWindow$5.actionPerformed(FHMSMainWindow.java:197) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at org.jdesktop.swingx.JXHyperlink.fireActionPerformed(JXHyperlink.java:244) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6038) at javax.swing.JComponent.processMouseEvent(JComponent.java:3260) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)Caused by: java.lang.NoSuchMethodException: Unknown property 'squid_quantity' on class 'class com.fhms.details.DailyReturnsDetails' at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1313) at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762) at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426) at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:111) ... 41 moreBUILD SUCCESSFUL (total time: 1 minute 23 seconds) Code:Below is the code of the Report managerpackage com.fhms.reporting;import com.fhms.details.DailyReturnsDetails;import java.io.InputStream;import java.util.Collection;import java.util.Map;import net.sf.jasperreports.engine.JRDataSource;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;import net.sf.jasperreports.view.JasperViewer;public class ReportManager { private InputStream reportInputStream; private JasperPrint jasperPrint = new JasperPrint(); private JRDataSource reportDataSource; private JasperViewer jasperViewer; public void showReport(Map reportParams, Collection<DailyReturnsDetails> entityJavaBeans, String reportFileName) { try { this.reportInputStream = ReportManager.class.getResourceAsStream(reportFileName); this.reportDataSource = new JRBeanCollectionDataSource(entityJavaBeans); System.out.println("Data source : " + reportDataSource); jasperPrint = JasperFillManager.fillReport(reportInputStream, reportParams, reportDataSource); this.jasperViewer = new JasperViewer(jasperPrint,false); this.jasperViewer.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }}Below is the code that converts the details of the reportpackage com.fhms.reporting;import com.fhms.details.DailyReturnsDetails;import com.fhms.entities.DailyReturns;import java.util.ArrayList;import java.util.List;public class DailyReturnsConverter{ public static List<DailyReturnsDetails> convertToDetails(List<DailyReturns> listOfDailyReturns) { List<DailyReturnsDetails> listOfDailyReturnsDetails = new ArrayList<DailyReturnsDetails>(); for(DailyReturns dailyReturns : listOfDailyReturns) { DailyReturnsDetails dailyReturnsDetails = new DailyReturnsDetails(); dailyReturnsDetails.setDateOfArrival(String.valueOf(dailyReturns.getDateOfArrival())); dailyReturnsDetails.setVessel(dailyReturns.getVessel()); dailyReturnsDetails.setRedfishQuantity(String.valueOf(dailyReturns.getRedfishQuantity())); dailyReturnsDetails.setSquidQuantity(String.valueOf(dailyReturns.getSquidQuantity())); dailyReturnsDetails.setOtherFishesQuantity(String.valueOf(dailyReturns.getOtherFishesQuantity())); dailyReturnsDetails.setNumberOfCrates(String.valueOf(dailyReturns.getNumberOfCrates())); dailyReturnsDetails.setNumberOfKilos(String.valueOf(dailyReturns.getNumberOfKilos())); dailyReturnsDetails.setMetricTonnes(String.valueOf(dailyReturns.getMetricTonnes())); listOfDailyReturnsDetails.add(dailyReturnsDetails); } return listOfDailyReturnsDetails; }}Below is how I call it behind a hyperlink Map parameters = new HashMap(); ReportManager reportManager = new ReportManager(); List<DailyReturns> listOfDailyReturns = FHMSDatastore.getFHMSDatastore().getAllDailyReturns(); List<DailyReturnsDetails> listOfDailyReturnDetails = DailyReturnsConverter.convertToDetails(listOfDailyReturns); reportManager.showReport(parameters, listOfDailyReturnDetails,"/com/fhms/reportfiles/DailyReturnsReports_1.jasper"); Link to comment Share on other sites More sharing options...
atsu Posted August 12, 2010 Author Share Posted August 12, 2010 This is my first time of using this site, how do I read the views and replies. please help me out Link to comment Share on other sites More sharing options...
lucianc Posted August 14, 2010 Share Posted August 14, 2010 If you use a bean data source, the filed names or descriptions need to match the properties of the beans. So use squidQuantity instead of squid_quantity as field name or description.HTH,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now