Thursday 7 March 2013

JasperReport example using eclipse

1) Structure of Employee Report example

 

   

2) Add below list of jar files in EmployeeReport example

commons-beanutils-1.7.jar
commons-collections-3.1.jar
commons-digester-1.8.jar
commons-lang-2.1.jar
commons-logging-1.1.jar
iText-1.3.jar
jasperreports-1.0.3.jar
ojdbc14.jar

3)  create table like this below
create table Employee(
First_Name  VARCHAR2(10),
Last_Name VARCHAR2(10)
);

insert into Employee values('satyam','reddy');
insert into Employee values('pallavi','reddy');




4) create a jrxml folder in your EmployeeReport Project
     In side jrxml folder create EmployeeReport.jrxml file and paste below code in inside that file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="EmployeeReport_Satyamsoft">
<queryString>
<![CDATA[select First_Name, Last_Name from employee e]]>
</queryString>
<field name="First_Name" />
<field name="Last_Name" />
<title>
<band height="50">
<staticText>
<reportElement x="0" y="0" width="180" height="15"/>
<textElement/>
<text><![CDATA[Jasper Report - satyamsoft]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="30">
<staticText>
<reportElement x="0" y="0" width="69" height="24" />
<textElement verticalAlignment="Bottom" />
<text>
<![CDATA[First Name: ]]>
</text>
</staticText>
<staticText>
<reportElement x="140" y="0" width="79" height="24" />
<text>
<![CDATA[Last Name: ]]>
</text>
</staticText>
</band>
</pageHeader>
<detail>
<band height="30">
<textField>
<reportElement x="0" y="0" width="69" height="24" />
<textFieldExpression>
<![CDATA[$F{First_Name}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="140" y="0" width="69" height="24" />
<textFieldExpression>
<![CDATA[$F{Last_Name}]]>
</textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>


5) create ReportGenerator class and paste inside this class

package com.satyamsoft;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;

public class ReportGenerator {

Connection conn;

public void generateReport() {

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","123456");
System.out.println("Loading Report Designs");
InputStream input = new FileInputStream(new File("jrxml/EmployeeReport.jrxml"));
JasperDesign jasperDesign = JRXmlLoader.load(input);

System.out.println("Compiling Report Designs");
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

System.out.println("Creating JasperPrint Object");
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("ReportTitle", "PDF JasperReport");

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,null,conn);

//Exporting the report
OutputStream output = new FileOutputStream(new File("report/EmployeeReport.pdf"));

JasperExportManager.exportReportToPdfStream(jasperPrint, output);

System.out.println("Report Generation Complete");
conn.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (JRException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
new ReportGenerator().generateReport();
}
}




6) After executing the class we will get EmployeeReport.pdf file in our report folder then the pdf file looks like below

 

51 comments:

  1. Hi Satyam,
    Thanks for a clean & tidy example for jasper reports. I found it the most easy to get start with jasper reporting tool form all the search i did. I require your help on how we can generate a jasper report in web application(JSP) with the data dynamically taken from Database.. Please guide me in this direction ... thanks and keep up the good work..!

    ReplyDelete
  2. it work for me, thank you so much.

    ReplyDelete
  3. good example for beginner like me,Thank you.

    ReplyDelete
  4. Hi Satyam, if i change formatt in jrxml file it is not compiling and giving SAXParseException. Do you have any idea on this..

    Thanks
    Java for Beginners

    ReplyDelete
    Replies
    1. Hi GeekaDude, as you mentioned in the above comment can you tell me where you wanna change the format in jrxml file. Actually this jrxml file code is creating inside the iReport tool as per we design.

      Delete
  5. The report design can be also created using DynamicReports. This library allows to create jasper report designs at runtime, it is easy to use and it is open source.
    http://www.dynamicreports.org/

    ReplyDelete
  6. Hi Satyam i am able to generate the report but my report pdf file is empty

    ReplyDelete
  7. Hi Satyam thanks a lot I am done now now I am able to see the records in my pdf...thanks it was really helpful for me ..

    ReplyDelete
  8. Thanks for your valuable post.
    I have one doubt with it If my report is containing su breport then how will I get the jasper file for that sub report.When I am trying this same code for one report then its is working fine but if that report is containing sub report then its is giving me error sub report.jasper is not found.

    ReplyDelete
    Replies
    1. Hello Tiwari Thanks for your comment. As you mentioned in the above comment how many reports are using. Do you want to execute multiple reports at a time ? And can you post the code of your entire project.

      Delete
    2. package jasper_automation;

      import java.io.File;
      import java.io.FileInputStream;
      import java.io.FileNotFoundException;
      import java.io.FileOutputStream;
      import java.io.InputStream;
      import java.io.OutputStream;
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.SQLException;
      import java.util.HashMap;
      import java.util.Map;


      import net.sf.jasperreports.engine.JRException;
      import net.sf.jasperreports.engine.JRResultSetDataSource;
      import net.sf.jasperreports.engine.JasperCompileManager;
      import net.sf.jasperreports.engine.JasperExportManager;
      import net.sf.jasperreports.engine.JasperFillManager;
      import net.sf.jasperreports.engine.JasperPrint;
      import net.sf.jasperreports.engine.JasperReport;
      import net.sf.jasperreports.engine.design.JasperDesign;
      import net.sf.jasperreports.engine.xml.JRXmlLoader;
      public class JasperDesign_new {

      Connection conn;

      public void generateReport() {

      try {
      Class.forName("com.mysql.jdbc.Driver");
      conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jas","root", "admin");
      System.out.println("Loading Report Designs");
      InputStream input = new FileInputStream(new File("jrxml/EmployeeReport.jrxml"));
      JasperDesign jasperDesign = JRXmlLoader.load(input);

      System.out.println("Compiling Report Designs");
      JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

      System.out.println("Creating JasperPrint Object");
      Map parameters = new HashMap();
      parameters.put("ReportTitle", "PDF JasperReport");

      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,null,conn);

      //Exporting the report
      OutputStream output = new FileOutputStream(new File("report/EmployeeReport.pdf"));

      JasperExportManager.exportReportToPdfStream(jasperPrint, output);

      System.out.println("Report Generation Complete");
      conn.close();
      } catch (FileNotFoundException e) {
      e.printStackTrace();
      } catch (JRException e) {
      e.printStackTrace();
      } catch (ClassNotFoundException e) {
      e.printStackTrace();
      } catch (SQLException e) {
      e.printStackTrace();
      }
      }

      public static void main(String[] args) {
      new JasperDesign_new().generateReport();
      }
      }

      Delete
  9. Above is my java code:

    I just take your sample employee.jrxml and added one sub report in it with any parameters. But while compiling it is giving me error subreport.jasper not found .I want to compile all sub reports on the fly while compiling the master report. as it is doing it in ireport.If I am compiling sub report separately it is working fine but it causes me to manually compile all sub -reports. I want a way to compile all the sub-reports with in Master report. Please Guide

    ReplyDelete
  10. hello sir, actually i wnt to import jasperreports library in eclipse. will u tell me how to do that

    ReplyDelete
    Replies
    1. U mean .jar files? And are you using Eclipse?

      Delete
  11. thanks a lot sir it helps me lot rather than all example i went through..
    but one problem is there i have keep all this code in ecl;ipse when i hit on submit button pdf file is generating but to see that file i have to close the eclipse and then have to open if i havent do like that it shows the here is problem in opening the file as this file is use in another application.. so what i have to do so that inspite of closing the eclipse pdf file file should open... plz reply..

    ReplyDelete
  12. Hi,
    as you mentioned in the above comment your are telling "hit on submit button". I wrote simple java code and didn't use any submit button. I run above example in eclipse by right click on the example select Run As >> Java Application.After doing this process automatically pdf file will be create in your destination folder. So could you please give breaf explanation on your doubt.

    ReplyDelete
  13. ya my file is creating on my my destination folder but when i am going to open that pdf file pdf reader says that this file is use in another application...(as it is open in eclipse or server that we use in eclipse is running ) and when i stop the server or close eclipse my pdf get open so i want to open pdf file when eclipse server is on or eclipse is open...mean opening of pdf file will not be depend on eclipse setting it should be independent...

    ReplyDelete
  14. nw i have taken the pdf file from the location where it is genenrated and copy and past it in another folder then it is opening...without stoping server...but any another way is there

    ReplyDelete
  15. now i have one anpther problem while creating report using i report tool 5.5 i have used the database query but i want to use functions in it for dyanamic report genration...i am using postgresql where and how i add function in that...???

    ReplyDelete
  16. *Is it possible to configure OUTPUT_FILE_NAME using iReport?

    ReplyDelete
  17. sir i try the same it is working fine for me .now i am planing to apply the same for my struts2 web application can you please suggest me any idea for the same

    ReplyDelete
  18. can anyone have working example.. i want to apply it in SWT(Standard Widget Toolkit)

    ReplyDelete
  19. sir,how do i create the jrxml file in eclipse.It is showing options for only xml even after adding the jars

    ReplyDelete
    Replies
    1. Copy above jrxml code in a notepad and save as EmployeeReport.jrxml file.
      Then this EmployeeReport.jrxml file copy and then paste in jrxml folder in eclipse project. Please check first point "Structure of the Employee Report example".

      Delete
  20. Hi SatyamReddy,

    Your piece of code which you have shared is very helpful.
    I have a question could you please resolve it,
    1. Am getting error like
    Loading Report Designs
    4854 [main] WARN org.apache.commons.digester.Digester - Parse Warning Error at line 99 column 326: schema_reference.4: Failed to read schema document 'http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
    org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
    at .................

    2. Is it required compulsory that we should have iReport application in same system where we are executing this code

    3. I need solution as poonam discussed with you. If i keep that jrxml code in application server is that more than enough are should do some change.

    Thanks in Advance,
    Pallavi Thota

    ReplyDelete
    Replies
    1. We are using jasperreports-1.0.3.jar file in above application. So no need iReport application in the same system for executing this code.

      Delete
    2. No need to do any changes if keep above jrxml code in application server.

      Delete
  21. sir please reply me for my above question?????/

    ReplyDelete
  22. will it be applicable for net beans

    ReplyDelete
    Replies
    1. Actually i didn't try. I think it's applicable.

      Delete
    2. actually i have applied it to net beans,its running and pdf file is also generated but its empty.... pls help me out

      Delete
  23. sir i use phpmyadmin for mysql so i add mysql connector jar and remove odbc.jar so i have no any output but i face following error please help me
    output is

    Loading Report Designs
    May 31, 2014 5:10:39 PM org.apache.commons.digester.Digester endElement
    SEVERE: End event threw error
    java.lang.NoClassDefFoundError: org/apache/commons/beanutils/MethodUtils
    at org.apache.commons.digester.CallMethodRule.end(CallMethodRule.java:626)
    at org.apache.commons.digester.Rule.end(Rule.java:253)
    at org.apache.commons.digester.Digester.endElement(Digester.java:1222)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endNamespaceScope(XMLDTDValidator.java:2054)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2005)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:879)
    and so on

    ReplyDelete
    Replies
    1. Did you add all the jar files, like commons-digester-1.8.jar file.

      Delete
    2. yes sir i add all jar files which u mention but from this line
      JasperDesign jasperDesign = JRXmlLoader.load(input);
      ececutin is not flow.
      i make one database name employee1 and in this data base create one table name employee and in this i create field firstname and last name.
      and i also change two line i remove your
      Class.forName("oracle.jdbc.driver.OracleDriver");
      conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","123456");
      and add the two lines
      Class.forName("com.mysql.jdbc.Driver");
      conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee1", "root", "root");
      and also remove ojdbc14.jar and add sql connector.jar

      please help me why showing error which i described

      Delete
    3. after adding all jar files i face following line of error
      java.io.IOException: Cannot run program "javac": error=2, No such file or directory and so on...help me

      Delete
    4. hii sir i run sucessfully your demo. problem was in ubuntu. so when i write same on windows then its work without error.
      i use this mysql with phpmyadmin. so change two database connection lines
      Class.forName("com.mysql.jdbc.Driver");
      conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee1", "root", "root");

      i ask you if i want to name specified on each field then where i code just like when i fatch data of firest name then in pdf file upper heading is like first name and below this all first name listed...just like last name and so on to different field....
      please answer me

      Delete
  24. This comment has been removed by the author.

    ReplyDelete
  25. actually i have applied it to net beans,its running and pdf file is also generated but its empty.... pls help me out

    ReplyDelete
  26. Hi Sir,
    I am having trouble with generating report using eclipse. I am using JasperStudio plugin, i have added all the jars, and i am using mysql database using xampp.

    I really need help as soon as possible.
    Please guide me.

    ReplyDelete
  27. stack trace: SEVERE: Error instantiating extensions registry for simple.font.families
    net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '
    net/sf/jasperreports/fonts/pictonic/pictonic.ttf
    net/sf/jasperreports/fonts/pictonic/pictonic.svg
    net/sf/jasperreports/fonts/pictonic/pictonic.eot
    net/sf/jasperreports/fonts/pictonic/pictonic.woff
    ' is not available to the JVM. See the Javadoc for more details.
    at net.sf.jasperreports.engine.util.JRFontUtil.checkAwtFont(JRFontUtil.java:358)
    at net.sf.jasperreports.engine.fonts.SimpleFontFamily.createFontFace(SimpleFontFamily.java:320)
    at net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(SimpleFontFamily.java:85)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:233)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:204)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:173)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:142)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory.createRegistry(SimpleFontExtensionsRegistryFactory.java:63)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.instantiateRegistry(DefaultExtensionsRegistry.java:238)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:213)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:162)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:132)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:104)
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.findComponentBundles(ComponentsEnvironment.java:90)
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.getCachedComponentBundles(ComponentsEnvironment.java:78)
    at net.sf.jasperreports.engine.component.ComponentsEnvironment.getComponentBundles(ComponentsEnvironment.java:66)
    at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:157)
    at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.configureParser(JRReportSaxParserFactory.java:138)
    at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:103)
    at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1338)
    at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1313)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:205)
    at com.report.ReportGenerator.generateReport(ReportGenerator.java:39)
    at com.report.ReportGenerator.main(ReportGenerator.java:69)

    ReplyDelete
  28. Jun 06, 2014 9:36:58 PM net.sf.jasperreports.engine.component.ComponentsEnvironment findComponentBundles
    WARNING: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components
    Jun 06, 2014 9:36:58 PM net.sf.jasperreports.engine.component.ComponentsEnvironment findComponentBundles
    WARNING: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components
    Jun 06, 2014 9:37:00 PM org.apache.commons.digester.Digester error
    SEVERE: Parse Error at line 3 column 452: cvc-complex-type.3.2.2: Attribute 'uuid' is not allowed to appear in element 'jasperReport'.
    org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 452; cvc-complex-type.3.2.2: Attribute 'uuid' is not allowed to appear in element 'jasperReport'.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
    net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 452; cvc-complex-type.3.2.2: Attribute 'uuid' is not allowed to appear in element 'jasperReport'.
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:245)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:228)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:216)
    at com.report.ReportGenerator.generateReport(ReportGenerator.java:39)
    at com.report.ReportGenerator.main(ReportGenerator.java:69)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 452; cvc-complex-type.3.2.2: Attribute 'uuid' is not allowed to appear in element 'jasperReport'.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
    ...

    ReplyDelete
  29. I am new to jasper reports.Above is the stack trace. Please guide me.

    ReplyDelete
  30. I want to call jasper report through servlet with dynamic data from database...

    i tried but cant find out any solution...

    please help me...

    thanx in advance....

    ReplyDelete
  31. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. In the above example i have used iReport 4.2. If you use latest version of iReport you will get these type of errors.

      Refer to below links

      https://community.jaspersoft.com/questions/843645/errorwith-jasper-56-jar

      http://stackoverflow.com/questions/19978524/jasper-report-font-error

      Delete
    2. hi,
      i need put a logo in the report can you help me

      Delete
  32. Follow below link. In the image of option number 6 in the right hand side in the options of " Palette" you can get image option. There you can can get option to select image. Click on the image and drag on the Designer form.

    http://satyamsoft.blogspot.com/2013/09/how-to-create-pdf-file-through-database.html

    ReplyDelete
  33. Dear Sir,

    I am using iReport 5.6.0 and trying to integrate the .jrxml file with eclipse luna latest version.I am getting the exception but the .jasper report is produced which is not able to read

    Stack trace:

    Dec 16, 2014 12:44:31 PM org.apache.commons.digester.Digester error
    SEVERE: Parse Error at line 2 column 466: Document root element "jasperReport", must match DOCTYPE root "null".
    org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 466; Document root element "jasperReport", must match DOCTYPE root "null".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1599)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1877)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:742)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1322)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1275)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3063)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:881)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at org.apache.commons.digester.Digester.parse(Digester.java:1745)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:236)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:223)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:211)
    at com.satyamsoft.ReportGenerator.generateReport(ReportGenerator.java:38)
    at com.satyamsoft.ReportGenerator.main(ReportGenerator.java:68)

    please do reply

    ReplyDelete
    Replies
    1. Sir,

      I had missed out apache-collections-commons-collections-3.1.jar added it after that I faced servlet exception for that I added javax.servlet.jar after that I was facing jasper report older version so i downloaded jasperreports -5.5.0 jar then came the itext old version exception for resolving that i added iText-5.0.5 jar file then came the Exception in thread "main" java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException...for this I added the com.lowagie.text-2.1.7.jar finally I got the output:)
      I deleted all old jar files of the above said and added the new jar files to my classpath and to Tomcat lib folder after that I got the .pdf generated

      Delete
    2. I'm glad you finally got it. We have to use different versions to get the output.

      Delete