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)
dynamic tabel creation problem
purushdk
Hi,
I am getting error in java console while running file
package com;
import java.io.IOException;
import java.util.ArrayList;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.model.api.CellHandle;
import org.eclipse.birt.report.model.api.DataItemHandle;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.OdaDataSetHandle;
import org.eclipse.birt.report.model.api.OdaDataSourceHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.RowHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.TableHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;
import org.eclipse.birt.report.model.api.elements.structures.ComputedColumn;
import com.ibm.icu.util.ULocale;
/**
* Dynamic Table BIRT Design Engine API (DEAPI) demo.
*/
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 DECreateDynamicTable {
static void executeReport() throws EngineException
{
IReportEngine engine=null;
EngineConfig config = null;
try{
config = new EngineConfig( );
config.setEngineHome( "/home/manavsoft/Desktop/eclipse/feature/org.eclipse.birt.report.runtime_2.3.2.v20090331-1440");
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();
}
//open the report design
IReportRunnable design = null;
design = engine.openReportDesign("/home/temp/BIRT/acceptandorder.rptdesign");
//Create task to run the report - use the task to run the report,
IRunTask task = engine.createRunTask(design);
//Run the report and create the rptdocument
task.run("/home/temp/BIRT/acceptandorder.rptdocument");
//Open the rptdocument
IReportDocument rptdoc = engine.openReportDocument("/home/temp/BIRT/acceptandorder.rptdocument");
//Create the data extraction task
IDataExtractionTask iDataExtract = engine.createDataExtractionTask(rptdoc);
/**
* returns the metadata corresponding to the data stored in the report
* document. Could specify a component.
*/
ArrayList resultSetList = (ArrayList)iDataExtract.getResultSetList( );
//Get the first result set. Note this is a table elemenent
IResultSetItem resultItem = (IResultSetItem)resultSetList.get( 0 );
//Set the name of the element you want to retrieve.
//This will usually be ELEMENT_something if you do not name your elements.
//If you name a table for example "MyTable" this will be the resultset name
String dispName = resultItem.getResultSetName( );
iDataExtract.selectResultSet( dispName );
IExtractionResults iExtractResults = iDataExtract.extract();
IDataIterator iData = null;
//Iterate the results
try{
if ( iExtractResults != null ) {
iData = iExtractResults.nextResultIterator( );
if ( iData != null ){
//Get metadata on retrieved results
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( ) ) {
//Just disply the first two columns
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();
}
//close the task and showdown the engine and Platform
//Note - If the program stays resident do not shutdown the Platform or the Engine
iDataExtract.close();
engine.destroy();
Platform.shutdown();
System.out.println("Finished");
}
public static void main(String[] args) {
try
{
executeReport( );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
Error
org.eclipse.birt.core.exception.BirtException: Cant startup the OSGI framework
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:91)
at com.DECreateDynamicTable.executeReport(DECreateDynamicTable.java:59)
at com.DECreateDynamicTable.main(DECreateDynamicTable.java:155)
Caused by: org.eclipse.birt.core.exception.BirtException: Could not start the Framework - /home/manavsoft/Desktop/eclipse/feature/org.eclipse.birt.report.runtime_2.3.2.v20090331-1440
at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:87)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:79)
... 2 more
java.lang.NullPointerException
at com.DECreateDynamicTable.executeReport(DECreateDynamicTable.java:72)
at com.DECreateDynamicTable.main(DECreateDynamicTable.java:155)
Thanks & Regards,
k.purushothaman
Find more posts tagged with
Comments
mwilliams
Hi k.purushothaman,
Is this the first time you've encountered this issue? Have you successfully created other java projects without this error?