Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » create ReportEngine failed
create ReportEngine failed [message #368741] Tue, 23 June 2009 06:59 Go to next message
xing tongkun is currently offline xing tongkunFriend
Messages: 1
Registered: July 2009
Junior Member
I use the birt 2.3.2.2 to create a report using API.The following is the
code:
package com.test.birt.report;

import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;

public class MyReportCreator {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
final EngineConfig config = new EngineConfig();

config.setBIRTHome("D:/work/libs/birt-runtime-2_3_2/ReportEngine ");

try {
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory)
Platform.createFactoryObject(IReportEngineFactory.EXTENSION_ REPORT_ENGINE_FACTORY);

IReportEngine engine = factory.createReportEngine(config);

} catch (BirtException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

when I run it ,it throws the following error message:
Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.birt.report.engine.api.impl.ReportEngine$EngineE xtensionManager. <init>(ReportEngine.java:794)
at
org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEngine.java:105)
at
org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$ 1.run(ReportEngineFactory.java:18)
at
org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$ 1.run(ReportEngineFactory.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.birt.report.engine.api.impl.ReportEngineFactory. createReportEngine(ReportEngineFactory.java:14)
at com.test.birt.report.MyReportCreator.main(MyReportCreator.ja va:24)


how can I do with it?
Re: create ReportEngine failed [message #368767 is a reply to message #368741] Wed, 24 June 2009 15:49 Go to previous message
Eclipse UserFriend
Originally posted by: jasonweathersby.windstream.net

Can you try this example. Make sure to mod the birt home.



package org.eclipse.birt.examples.reapi;



import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.PDFRenderOption;

import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler;
import org.eclipse.birt.report.engine.api.IGetParameterDefinitionTa sk;
import org.eclipse.birt.report.engine.api.IParameterSelectionChoice ;

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;
import org.eclipse.birt.report.engine.api.RenderOption;

import org.eclipse.birt.report.engine.api.IParameterDefnBase;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SlotHandle;


public class RunAndRenderTask {

public void runReport() throws EngineException
{

IReportEngine engine=null;
EngineConfig config = null;

try{
config = new EngineConfig( );

config.setBIRTHome(" C:\\birt\\birt-runtime-2_3_2\\birt-runtime-2_3_2\\ReportEngi ne ");
config.setLogConfig(null, 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("Reports/topNPercent.rptdesign");
ReportDesignHandle rdh = (ReportDesignHandle)design.getDesignHandle();

IRunAndRenderTask task = engine.createRunAndRenderTask(design);

Map rpMap = new HashMap();
rpMap.put("Top Count", 15);
rpMap.put("Top Percentage", 5);
task.setParameterValues(rpMap);




HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFileName("output/resample/TopNPercent.html ");
options.setOutputFormat("HTML");
//options.setHtmlRtLFlag(false);
options.setImageDirectory("output/resample/images");
options.setEnableAgentStyleEngine(true);
options.setEmbeddable(true);

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
{

RunAndRenderTask ex = new RunAndRenderTask( );
ex.runReport();

}
catch ( Exception e )
{
e.printStackTrace();
}
}

}

Jason

xing tongkun wrote:
> I use the birt 2.3.2.2 to create a report using API.The following is the
> code:
> package com.test.birt.report;
>
> import org.eclipse.birt.core.exception.BirtException;
> import org.eclipse.birt.core.framework.Platform;
> import org.eclipse.birt.report.engine.api.EngineConfig;
> import org.eclipse.birt.report.engine.api.IReportEngine;
> import org.eclipse.birt.report.engine.api.IReportEngineFactory;
>
> public class MyReportCreator {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> // TODO Auto-generated method stub
> final EngineConfig config = new EngineConfig();
>
> config.setBIRTHome("D:/work/libs/birt-runtime-2_3_2/ReportEngine ");
>
> try {
> Platform.startup(config);
> IReportEngineFactory factory = (IReportEngineFactory)
> Platform.createFactoryObject(IReportEngineFactory.EXTENSION_ REPORT_ENGINE_FACTORY);
>
>
> IReportEngine engine = factory.createReportEngine(config);
>
> } catch (BirtException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
>
> }
>
> when I run it ,it throws the following error message:
> Exception in thread "main" java.lang.NullPointerException
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngine$EngineE xtensionManager. <init>(ReportEngine.java:794)
>
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEngine.java:105)
>
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$ 1.run(ReportEngineFactory.java:18)
>
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$ 1.run(ReportEngineFactory.java:1)
>
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngineFactory. createReportEngine(ReportEngineFactory.java:14)
>
> at com.test.birt.report.MyReportCreator.main(MyReportCreator.ja va:24)
>
>
> how can I do with it?
>
Previous Topic:The report contains error bug
Next Topic:Draw line, rectangle etc..
Goto Forum:
  


Current Time: Sun Dec 21 14:30:38 GMT 2014

Powered by FUDForum. Page generated in 0.02439 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software