IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Eclipse Java Discussion :

Intégrer un rapport Birt


Sujet :

Eclipse Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    36
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations forums :
    Inscription : Décembre 2008
    Messages : 36
    Par défaut Intégrer un rapport Birt
    Bonjour,
    J'ai cré un simple rapport dans Birt et je veux l'intégrer dans ma classe java.
    Voilà mon code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    package Package1;
     
    import java.util.ArrayList;
    import java.util.logging.Level;
     
    import org.eclipse.birt.core.framework.Platform;
    import org.eclipse.birt.data.engine.core.DataException;
    import org.eclipse.birt.report.engine.api.EngineConfig;
    import org.eclipse.birt.report.engine.api.EngineException;
    import org.eclipse.birt.report.engine.api.IDataExtractionTask;
    import org.eclipse.birt.report.engine.api.IDataIterator;
    import org.eclipse.birt.report.engine.api.IExtractionResults;
    import org.eclipse.birt.report.engine.api.IReportDocument;
    import org.eclipse.birt.report.engine.api.IReportEngine;
    import org.eclipse.birt.report.engine.api.IReportEngineFactory;
    import org.eclipse.birt.report.engine.api.IReportRunnable;
    import org.eclipse.birt.report.engine.api.IResultMetaData;
    import org.eclipse.birt.report.engine.api.IResultSetItem;
    import org.eclipse.birt.report.engine.api.IRunTask;
     
     
    public class Edition {
     
    static void executeReport() throws EngineException
    {
     IReportEngine engine=null;
     EngineConfig config = null;
     try{
      config = new EngineConfig( );
      config.setEngineHome( "E:\\eclipse\\features\\org.eclipse.birt.report.runtime_2.2.2.r22x_v20071015-7U7U7RBs-_N6u3VW7eooU" );
      config.setLogConfig(null, Level.FINE);
     
      Platform.startup( config );
      IReportEngineFactory factory = (IReportEngineFactory) Platform
      .createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
      engine = factory.createReportEngine( config );
      engine.changeLogLevel( Level.WARNING );
     
     }catch( Exception ex){
      ex.printStackTrace();
     }
     
     IReportRunnable design = null;
     
     design = engine.openReportDesign("C:\\Documents and Settings\\Administrateur\\Travail\\MonPremier\\src\\Package1\\ListePro.rptdesign"); 
     
     IRunTask task = engine.createRunTask(design); 
     
     task.run("C:\\acceptandorder.rptdocument");
     
     
     IReportDocument rptdoc = engine.openReportDocument("C:\\acceptandorder.rptdocument"); 
     
     IDataExtractionTask iDataExtract = engine.createDataExtractionTask(rptdoc);
     
     
     ArrayList resultSetList = (ArrayList)iDataExtract.getResultSetList( );
     
     
     IResultSetItem resultItem = (IResultSetItem)resultSetList.get( 0 );
     
     String dispName = resultItem.getResultSetName( );
     iDataExtract.selectResultSet( dispName );
     
     IExtractionResults iExtractResults = iDataExtract.extract();
     IDataIterator iData = null;
     
     try{
      if ( iExtractResults != null ) {
        iData = iExtractResults.nextResultIterator( );
        if ( iData != null  ){
     
          IResultMetaData irmd = iData.getResultMetaData();
          int colCount = irmd.getColumnCount();
          System.out.println("Column Count =" + colCount );
          for( int j=0; j< colCount; j++){
            System.out.println("Column Name =" + irmd.getColumnName(j) );
            System.out.println("Column Type =" + irmd.getColumnTypeName(j) );
          }
     
          while ( iData.next( ) ) { 
     
            Object objColumn1;
            Object objColumn2;
            try{
              objColumn1 = iData.getValue(0);
            } catch(DataException e) {
              objColumn1 = new String("");
            }
     
            try{
              objColumn2 = iData.getValue(1);
            } catch(DataException e){
              objColumn2 = new String("");
            } 
     
            System.out.println( objColumn1 + " , " + objColumn2 );
          }
          iData.close();
        }
      }
     }catch( Exception e){
      e.printStackTrace();
     }
    Engine  
     iDataExtract.close();
     engine.destroy();
     Platform.shutdown();
     System.out.println("Finished");
    }
     
     
    public static void main(String[] args) {
     try
     {
      executeReport( );
     }
     catch ( Exception e )
     {
      e.printStackTrace();
     }
    }
     
    }





    Mais après l'exécusion j'obtient cet erreur.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    org.eclipse.birt.core.exception.BirtException: Can't startup the OSGI framework
    	at org.eclipse.birt.core.framework.Platform.startup(Platform.java:90)
    	at Package1.Edition.executeReport(Edition.java:33)
    	at Package1.Edition.main(Edition.java:129)
    Caused by: org.eclipse.birt.core.exception.BirtException: Could not find the Framework - {0}
    	at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:95)
    	at org.eclipse.birt.core.framework.Platform.startup(Platform.java:78)
    	... 2 more
    java.lang.NullPointerException
    	at Package1.Edition.executeReport(Edition.java:46)
    	at Package1.Edition.main(Edition.java:129)

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    36
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations forums :
    Inscription : Décembre 2008
    Messages : 36
    Par défaut Intégration d'un birt
    pour le problème signalé avant j'ai trouvé la solution.mais maintenant j'ai un autre problème.
    voilà le code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    package Package1;
     
    import java.util.HashMap;
    import java.util.logging.Level;
    import org.eclipse.birt.core.framework.Platform;
    import org.eclipse.birt.report.engine.api.EngineConfig;
    import org.eclipse.birt.report.engine.api.EngineConstants;
    import org.eclipse.birt.report.engine.api.EngineException;
    import org.eclipse.birt.report.engine.api.HTMLActionHandler;
    import org.eclipse.birt.report.engine.api.HTMLEmitterConfig;
    import org.eclipse.birt.report.engine.api.HTMLRenderContext;
    import org.eclipse.birt.report.engine.api.HTMLRenderOption;
    import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
    import org.eclipse.birt.report.engine.api.IReportEngine;
    import org.eclipse.birt.report.engine.api.IReportEngineFactory;
    import org.eclipse.birt.report.engine.api.IReportRunnable;
    import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
     
    public class ExecuteReport {
     
    	public static void executeReport() throws EngineException
    	{
     
    	IReportEngine engine=null;
    	EngineConfig config = null;
     
    	try{
    		config = new EngineConfig( );			
    		config.setBIRTHome("E:\\2008\\birt-runtime-2_2_2\\birt-runtime-2_2_2\\ReportEngine");
    		config.setLogConfig("c:/temp/test", Level.FINEST);
    		Platform.startup( config );
    		IReportEngineFactory factory = (IReportEngineFactory) Platform
    		.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
    		engine = factory.createReportEngine( config );		
     
    		IReportRunnable design = null;
    		//Open the report design
    		design = engine.openReportDesign("C:\\Documents and Settings\\Administrateur\\Travail\\MonPremier\\src\\Package1\\ListePro.rptdesign"); 
    		IRunAndRenderTask task = engine.createRunAndRenderTask(design); 		
    		//task.setParameterValue("Top Count", (new Integer(5)));
    		//task.validateParameters();
     
    		HTMLRenderOption options = new HTMLRenderOption();		
    		options.setOutputFileName("C:/Parmdisp.html");
    		options.setOutputFormat("html");
    		//options.setHtmlRtLFlag(false);
    		//options.setEmbeddable(false);
    		//options.setImageDirectory("C:\\test\\images");
     
    		//PDFRenderOption options = new PDFRenderOption();
    		//options.setOutputFileName("c:/temp/test.pdf");
    		//options.setOutputFormat("pdf");
     
    		task.setRenderOption(options);
    		task.run();
    		task.close();
    		engine.destroy();
    	}catch( Exception ex){
    		ex.printStackTrace();
    	}		
    	finally
    	{
    	       Platform.shutdown( );
    	}
     
     System.out.println("Finished");
    } 
    /**
     * @param args
     */
    public static void main(String[] args) {
     try
     {
    	 executeReport( );
     }
     catch ( Exception e )
     {
      e.printStackTrace();
     }
    }
     
    }



    et voilà ce qui me donne comme erreur:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/javascript/Scriptable
    	at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory.createReportEngine(ReportEngineFactory.java:13)
    	at Package1.ExecuteReport.executeReport(ExecuteReport.java:35)
    	at Package1.ExecuteReport.main(ExecuteReport.java:75)
    Caused by: java.lang.ClassNotFoundException: org.mozilla.javascript.Scriptable
    	at java.net.URLClassLoader$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    	... 3 more


    J'attends vos réponses.



    Merci.

  3. #3
    Membre éprouvé
    Avatar de Deadpool
    Homme Profil pro
    Inscrit en
    Novembre 2005
    Messages
    1 312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2005
    Messages : 1 312
    Par défaut
    A priori il te manque la librairie Rhino qui permet d'exécuter du code Javascript dans du code Java.

    Apparemment les libs Birt ont besoin de Rhino.

    Tu trouveras Rhino ici : http://www.mozilla.org/rhino/

Discussions similaires

  1. Peut on intégrer un PDF dans un rapport BIRT?
    Par TheTcha dans le forum BIRT
    Réponses: 5
    Dernier message: 12/12/2013, 10h50
  2. Réponses: 7
    Dernier message: 06/09/2011, 14h11
  3. Réponses: 8
    Dernier message: 03/02/2011, 16h42
  4. [2.3.2] Intégrer rapport Birt dans Plateforme Pentaho
    Par Nicolas281088 dans le forum BIRT
    Réponses: 0
    Dernier message: 09/04/2009, 23h56
  5. [SBI BIRT] Intégrer une template de rapport BIRT
    Par waelos dans le forum SpagoBI
    Réponses: 2
    Dernier message: 10/11/2008, 10h37

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo