6 Replies Latest reply: Nov 21, 2012 4:41 AM by fakhri.kharrat RSS

    Integration of jasper with adf jdev

    fakhri.kharrat
      hi,
      my jdev version is 11.1.2.3
      and am using Integratedweblogic

      I found this link http://sameh-nassar.blogspot.com/2009/10/using-jasper-reports-with-jdeveloper.html#comment-form


      I try to integrate jasper IReport 3.0 with jdev, i add these jar files into my classpath:

      1-commons-digester-1.7.jar
      2-itext-1.3.1.jar
      3-jasperreports-3.0.0.jar
      4-poi-3.0.1-final-20070705.jar
      5- jasper-compiler-jdt-5.5.15.jar


      In web.xml add this
      <resource-ref>
      <res-ref-name>java:comp/env/jdbc/gestDS</res-ref-name>
      <res-type> javax.sql.DataSource </res-type>
      <res-auth> Container </res-auth>
      </resource-ref>

      and in my backing bean i add these imports and methode

      import java.io.File;
      import java.io.FileInputStream;
      import java.io.FileNotFoundException;
      import java.io.IOException;
      import java.io.InputStream;

      import java.sql.Connection;
      import java.sql.SQLException;

      import java.util.HashMap;
      import java.util.Map;

      import javax.naming.InitialContext;
      import javax.naming.NamingException;

      import javax.sql.DataSource;

      import net.sf.jasperreports.engine.JRException;
      import net.sf.jasperreports.engine.JasperCompileManager;
      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;
      import net.sf.jasperreports.view.JasperViewer;


      public void printReport() throws FileNotFoundException, JRException, NamingException, SQLException, IOException {
      InputStream input = new FileInputStream(new File("c:/yourJasperReport.xml"));
      JasperDesign design = JRXmlLoader.load(input);
      JasperReport report = JasperCompileManager.compileReport(design);
      Map parameters = new HashMap();
      // parameters.put("jasperParamenterName", "ParameterValue"); Used if you want to pass a parameter to a jasper report
      InitialContext initialContext = new InitialContext();
      DataSource ds = (DataSource)initialContext.lookup("java:comp/env/jdbc/gestDS"); // get from your application module configuration
      Connection conn = ds.getConnection();
      JasperPrint print = JasperFillManager.fillReport(report, parameters, conn);

      JasperViewer.viewReport(print, true);
      }

      i add a method when clicking on the button but i did not make any reference to printReport()
      public String do_print() {
      // Add event code here...
      return null;
      }

      i add also the jar file in my C:\Oracle\MiddleJdev11.1.2.3\jdeveloper\jdev\lib


      when i run my app an error appear:

      java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException
           at java.lang.Class.getDeclaredMethods0(Native Method)
           at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
           at java.lang.Class.getDeclaredMethods(Class.java:1791)
           at oracle.adfinternal.controller.beans.AnnotationUtils.findAnnotatedMethods(AnnotationUtils.java:194)
      ....

      i found in many other forum using eclipse or netbeans that i have to add these files jar in WEB-INF/lib


      Please can you help me because we plan to use jasper in our reporting


      thanks

      Edited by: fakhri_tn on Nov 21, 2012 1:09 AM