pawel.kosciuk Posted February 27, 2013 Share Posted February 27, 2013 Hi, for last 2 days i'm trying to get jasperreports to work.I'm trying to create simple Java SE application. All the tutorials i found cover the jasper xml files, editing the report etc. I'm stuck being unable to find anything about how to properly configure jasperreports library and it's dependencies. Is there a tutorial somewhere how to set this up? All i find is:A) How to edit report xmlB) How to edit report.xml with iReports To setup project in Eclipse i tried:1) i added jasperreports-5.0.0.jar to buildpath, along with jasperreports-javaflow-5.0.0.jar, applet, and fonts (should I add those files too? If they are integral parts why are the jars separate?)2) i added dependancies to buildpath:commons-beanutils-1.8.3.jarcommons-collections-3.2.1.jarcommons-digester-1.7.jar (that was a pain to get. Apache Commons Digester site goes 403 Forbidden on Download page)commons-logging-1.1.1.jaritextpdf-5.4.0.jaritext-pdfa-5.4.0.jaritext-xtra-5.4.0.jar3) i created test applicationpublic static void main(String [] args) { JasperReport jasperReport; JasperPrint jasperPrint; try { jasperReport = JasperCompileManager.compileReport("hw.xml"); jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), new JREmptyDataSource()); JasperExportManager.exportReportToPdfFile(jasperPrint, "reports/simple_report.pdf"); } catch (JRException e) { e.printStackTrace(); }}the hw.xml file:--removed because it broke the post formatting --result: Feb 27, 2013 11:45:52 AM net.sf.jasperreports.engine.component.ComponentsEnvironment findBundles WARNING: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components Feb 27, 2013 11:45:52 AM net.sf.jasperreports.engine.component.ComponentsEnvironment findBundles WARNING: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components Feb 27, 2013 11:45:53 AM net.sf.jasperreports.engine.component.ComponentsEnvironment findBundles WARNING: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components Feb 27, 2013 11:45:53 AM net.sf.jasperreports.engine.xml.JRBandFactory createObject WARNING: The 'isSplitAllowed' attribute is deprecated. Use the 'splitType' attribute instead. Exception in thread "main" java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException at net.sf.jasperreports.engine.JasperExportManager.exportToPdfFile(JasperExportManager.java:145) at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:497) at Test.main(Test.java:21) Caused by: java.lang.ClassNotFoundException: com.lowagie.text.DocumentException at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 3 more Link to comment Share on other sites More sharing options...
Solution marianol Posted February 27, 2013 Solution Share Posted February 27, 2013 There is a very good full sample in the library download (download jasperreports-5.0.0-project.zip from http://community.jaspersoft.com/project/jasperreports-library/releases) and go to /jasperreports-5.0.0/demo/samples/webapp.That web application goes over the full lifecycle of a report from compilink the JRXML to exporting a PDF or other formats.Also check the tutorial here: http://community.jaspersoft.com/wiki/jasperreports-library-tutorial and you can find more resources and information here: http://community.jaspersoft.com/project/jasperreports-library/resources Link to comment Share on other sites More sharing options...
pawel.kosciuk Posted February 28, 2013 Author Share Posted February 28, 2013 Thank you for your answer. As i stated, i don't have trouble with creating Jasper xmls, or using JAsper library in my app code. I had trouble with setting up all JAsperReports dependencies. I work-arounded that by including every .jar in lib folder from jasperreports-5.0.0-project, but that does not solve the base issue which is lack of proper list of required libraries with links to download compatible versions of those libraries. The page here: http://community.jaspersoft.com/wiki/jasperreports-library-requirements didn't help because current iText releases are apparently incompatible with current JasperReports, amd commons-digester download page is not working. Right now i include all libs from jasperreports-5.0.0-project, including some that look like they are JSP/JavaEE stuff, making it 40MB of dependancies. Anyway, thanks for your help, I'll just have to remove libraries one by one and check if it breaks JasperReports. Link to comment Share on other sites More sharing options...
ing.elvisrodriguez Posted May 25, 2013 Share Posted May 25, 2013 Im using this code and im getting the error below: try{ try{ JasperDesign jps = JRXmlLoader.load("ReporteComprasPF.jrxml"); String sql = "select * from compras where fecha_c ='"+((JTextField)fdesde.getDateEditor().getUiComponent()).getText()+"'"; JRDesignQuery newquery = new JRDesignQuery(); newquery.setText(sql); jps.setQuery(newquery); JasperReport jsp = JasperCompileManager.compileReport(jps); JasperPrint jspp = JasperFillManager.fillReport (jsp,null,con); JasperViewer.viewReport(jspp); } catch (Exception ex){ JOptionPane.showMessageDialog(null, ex); } }catch (NumberFormatException efn){ JOptionPane.showMessageDialog(rootPane, efn); } may 25, 2013 2:30:43 PM net.sf.jasperreports.engine.component.ComponentsEnvironment findComponentBundles WARNING: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components may 25, 2013 2:30:43 PM net.sf.jasperreports.engine.component.ComponentsEnvironment findComponentBundles WARNING: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components 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