Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
calling Birt from remote application
loithoi
Hi,
I have a problem with running birt from another machine. I wrote a java program to start-up BIRT engine and run the report design file. I have java application on one machine and BIRT on another machine. When the java application run, it copies the java program to BIRT machine and execute it from there.
My java program had somthing like this:
public static String runBirtReport( byte[] reportDesign, HashMap params, String filename, String reportType ) throws IOException{
CLog log = CommonLog.getLog();
log.write( location, "Start Time= " + Calendar.getInstance().getTime().toString() );
log.write( location, "BIRT starts" );
log.write( location, "Filename: " + filename );
log.write( location, "Report Type: " + reportType );
log.write(location, "BirtClassPath= " + System.getProperty("java.class.path") );
ByteArrayInputStream bis = new ByteArrayInputStream( reportDesign );
try {
initializeBirt();
// open the report design file
IReportRunnable design = engine.openReportDesign( bis );
// set render option
RenderOption options = null;
String output = BIRT_REPOSITORY + filename;
if( reportType.equals( "PDF" ) ){
PDFRenderOption pdfOptions = new PDFRenderOption();
pdfOptions.setOutputFormat( PDFRenderOption.OUTPUT_FORMAT_PDF );
//output += ".pdf";
pdfOptions.setOutputFileName( output );
pdfOptions.setEmbededFont( true );
options = pdfOptions;
}
else if( reportType.equals( "XLS" ) ){
EXCELRenderOption xlsOptions = new EXCELRenderOption();
xlsOptions.setOutputFormat( "XLS" );
//output += ".xls";
xlsOptions.setOutputFileName( output );
options = xlsOptions;
}
/*else if( reportType.equals( "CSV" ) ){
CSVRenderOption csvOptions = new CSVRenderOption();
csvOptions.setOutputFormat( "CSV" );
output += ".csv";
csvOptions.setOutputFilename( output );
options = csvOptions;
}*/
else if( reportType.equals( "DOC" ) ){
options = new RenderOption();
options.setOutputFormat( "DOC" );
//output += ".doc";
options.setOutputFileName( output );
}
else{
HTMLRenderOption htmlOptions = new HTMLRenderOption();
htmlOptions.setOutputFormat( HTMLRenderOption.OUTPUT_FORMAT_HTML );
htmlOptions.setHtmlTitle( filename );
//output += ".html";
htmlOptions.setOutputFileName( output );
options = htmlOptions;
}
log.write( location, output );
IRunAndRenderTask task = engine.createRunAndRenderTask( design );
// set parameters
if( params != null )
task.setParameterValues( params );
// set render option
task.setRenderOption( options );
log.write( location, "Run Report" );
// run report
task.run();
task.close();
//shut down engine
//engine.destroy();
//Platform.shutdown();
/**
* we don't shut down the engine because we want to leave the engine
* on so that we can run the engine many times without start-up the engine
* again.
*/
log.write( location, "Birt runs successfully" );
bis.close();
log.write( location, "End Time= " + Calendar.getInstance().getTime().toString() );
return output;
}
catch ( EngineException ex ){
try{
engine.destroy();
Platform.shutdown();
}
catch(Exception e){}
log.write(location, ex.getMessage() );
return null;
}
catch( BirtException ex) {
try{
engine.destroy();
Platform.shutdown();
}
catch( Exception e){ }
log.write( location, "Cannot start-up engine");
log.write(location, ex.getMessage() );
return null;
}
}
When I run the program above manually on birt machine, it's running fine. However, when I run it with remote java application, it gives me errors
SEVERE: Error happened while running the report.
java.lang.ExceptionInInitializerError
at org.eclipse.birt.core.internal.function.impl.FunctionProviderImpl.ext
ractBoolean(FunctionProviderImpl.java:343)
at org.eclipse.birt.core.internal.function.impl.FunctionProviderImpl.get
ScriptFunction(FunctionProviderImpl.java:302)
at org.eclipse.birt.core.internal.function.impl.FunctionProviderImpl.get
CategoryMap(FunctionProviderImpl.java:198)
at org.eclipse.birt.core.internal.function.impl.FunctionProviderImpl.get
WrapperedCategories(FunctionProviderImpl.java:402)
at org.eclipse.birt.core.internal.function.impl.FunctionProviderImpl.reg
isterScriptFunction(FunctionProviderImpl.java:120)
at org.eclipse.birt.core.script.functionservice.impl.FunctionProvider.re
gisterScriptFunction(FunctionProvider.java:76)
at org.eclipse.birt.core.script.CoreJavaScriptInitializer.initialize(Cor
eJavaScriptInitializer.java:26)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.initWrapFa
ctory(JavascriptEngine.java:141)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.<init>(Jav
ascriptEngine.java:111)
at org.eclipse.birt.report.engine.javascript.JavascriptEngineFactory.cre
ateScriptEngine(JavascriptEngineFactory.java:76)
at org.eclipse.birt.core.script.ScriptContext.createEngine(ScriptContext
.java:238)
at org.eclipse.birt.core.script.ScriptContext.getScriptEngine(ScriptCont
ext.java:227)
at org.eclipse.birt.report.engine.adapter.ModelDteApiAdapter.<init>(Mode
lDteApiAdapter.java:177)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.<init>(Abs
tractDataEngine.java:103)
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.<init>(DteDataE
ngine.java:74)
at org.eclipse.birt.report.engine.data.DataEngineFactory.createDataEngin
e(DataEngineFactory.java:101)
at org.eclipse.birt.report.engine.executor.ExecutionContext.openDataEngi
ne(ExecutionContext.java:804)
at org.eclipse.birt.report.engine.executor.ExecutionContext.getDataEngin
e(ExecutionContext.java:826)
at org.eclipse.birt.report.engine.executor.ReportExecutor.execute(Report
Executor.java:123)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportEx
ecutor.execute(WrappedReportExecutor.java:60)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplciat
eReportExecutor.execute(SuppressDuplciateReportExecutor.java:42)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportEx
ecutor.execute(WrappedReportExecutor.java:60)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAnd
RenderTask.java:168)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRe
nderTask.java:75)
at BirtEngine.runBirtReport(BirtEngine.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.bdi.SPS.XML.JavaCodeItem.invokeStaticMethod(JavaCodeItem.java:415
)
I'm new to BIRT so help me out... thanks!
Find more posts tagged with
Comments
There are no comments yet