Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » createFactoryObject returning NULL
createFactoryObject returning NULL [message #1400508] Mon, 14 July 2014 09:55 Go to next message
Prashant Sonawane is currently offline Prashant SonawaneFriend
Messages: 2
Registered: July 2014
Junior Member
Hi,

I am trying to run BIRT report through standalone Java Code which I reference from Internet.
I am using BIRT-Runtime-4_4_0.
ReportEngine/Lib are configured in the Build Path. plugins folder is copied under the ReportEngine folder.

Following statement, factory is returning as NULL.

IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);


Following is the Java Code.

import java.util.logging.Level;




//import org.apache.log4j.Logger;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.IPlatformContext;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.core.framework.PlatformConfig;
import org.eclipse.birt.core.framework.PlatformFileContext;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.HTMLActionHandler;
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.springframework.beans.factory.DisposableBean;

/**
* Provides the init and startup of the birt engine and config.
*
* @author Roberto Nibali
* @author Erik Swenson
*
*/
public class ExecuteReport //implements DisposableBean
{
// protected static Logger log = Logger.getLogger(BirtProvider.class);

private static IReportEngine birtEngine = null;

@SuppressWarnings("unchecked")
public static synchronized IReportEngine getBirtEngine(String birtHome)
{
System.out.println("Report Generated Sucessfully11!!");
if (birtEngine == null)
{
// log.info("Starting BIRT Engine and OSGI Platform");

PlatformConfig platformConfig = new PlatformConfig();
platformConfig.setBIRTHome(birtHome);

System.out.println("Report Generated Sucessfully22!!");
IPlatformContext context = new PlatformFileContext(platformConfig);

HTMLServerImageHandler imageHandler = new HTMLServerImageHandler();

HTMLRenderOption emitterConfig = new HTMLRenderOption();
emitterConfig.setActionHandler(new HTMLActionHandler());
emitterConfig.setImageHandler(imageHandler);

EngineConfig config = new EngineConfig();
config.setEngineHome("");
config.setPlatformContext(context);
config.setLogConfig(null, Level.ALL);
config.getEmitterConfigs().put("html", emitterConfig);

try
{
Platform.startup(config);
}
catch (BirtException e)
{
// log.error("BirtException", e);
System.out.println("Exc: " + e);
}

IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);

birtEngine = factory.createReportEngine(config);

// log.info("BIRT Engine Started");
System.out.println("Report Generated Sucessfully!!");
}

birtEngine.changeLogLevel(Level.SEVERE);

return birtEngine;
}
public static void main(String[] args) {
try {
String bt = "C:/Telstra/Reporting/birt-runtime-4_4_0/ReportEngine";
getBirtEngine(bt);
System.out.println("Report Generated Sucessfully!!");
} catch (Exception e) {
e.printStackTrace();
}
}
public void destroy()
{
if (birtEngine == null) return;

birtEngine.destroy();
Platform.shutdown();
birtEngine = null;

//log.info("BIRT Engine and OSGI Platform Shutdown");
}
}
Re: createFactoryObject returning NULL [message #1402497 is a reply to message #1400508] Thu, 17 July 2014 04:25 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Try getting rid of the platformConfig and the set BIRTHome lines. Those are the first things I see that you probably don't need.

Michael

Developer Evangelist, Silanis
Previous Topic:show tabs like excel in web viewer
Next Topic:Can't open a .doc file generated by B.I.R.T with ActiveX
Goto Forum:
  


Current Time: Fri Mar 29 02:22:33 GMT 2024

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

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

Back to the top