Bonjour,
J'ai cré un simple rapport avec birt sous eclipse et une classe java auquelle je fais l'intégration de mon rapport.
Voilà le code:
package Package1;
import java.io.ByteArrayOutputStream;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
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 Edition extends JFrame
{
JEditorPane myEditorPane = null;
IReportEngine engine=null;
EngineConfig config = null;
Edition ()
{
myEditorPane = new JEditorPane ();
myEditorPane.setEditable(false);
JScrollPane scrollPane = new JScrollPane(myEditorPane);
JFrame myframe = new JFrame("BIRT Report");
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myframe.getContentPane().add(scrollPane);
myframe.setSize(600, 600);
myframe.setVisible(true);
}
public void runReport()
{
try
{
IReportRunnable design = null;
//Open the report design
design = engine.openReportDesign("C:/Documents and Settings/Administrateur/Travail/MonPremier/src/Package1/ListePro.rptdesign");
//Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
HTMLRenderOption options = new HTMLRenderOption();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
options.setOutputStream(bos);
options.setOutputFormat("html");
options.setEmbeddable(true);
task.setRenderOption(options);
task.run();
task.close();
myEditorPane.setContentType("text/html");
myEditorPane.setText(bos.toString());
System.out.println("Finished Gen");
}
catch( Exception ex)
{
ex.printStackTrace();
}
}
public void startPlatform(){
try
{
config = new EngineConfig( );
config.setBIRTHome("E:\\eclipse\\features\\org.eclipse.birt.report.runtime_2.2.2.r22x_v20071015-7U7U7RBs-_N6u3VW7eooU");
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
}
catch( Exception e)
{
e.printStackTrace();
}
}
public void stopPlatform()
{
engine.destroy();
Platform.shutdown();
}
public static void main (String[] args)
{
Edition html = new Edition ();
html.startPlatform();
System.out.println("Started");
html.runReport();
html.stopPlatform();
System.out.println("Finished");
}
}
Mais après l'exécusion voilà le résultat:
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.startPlatform(Edition.java:64)
at Package1.Edition.main(Edition.java:82)
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.runReport(Edition.java:39)
at Package1.Edition.main(Edition.java:84)
Exception in thread "main" java.lang.NullPointerException
Started
at Package1.Edition.stopPlatform(Edition.java:76)
at Package1.Edition.main(Edition.java:85)
J'ai rien compris de ce message.
J'ai besoin de votre aide.
Merci d'avance
Configuration: Windows 2000
Internet Explorer 6.0