Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » APIs error conection(APIs Report Generation error)
icon11.gif  APIs error conection [message #699705] Fri, 22 July 2011 07:01 Go to next message
richard  is currently offline richard Friend
Messages: 5
Registered: July 2011
Location: Germany
Junior Member

Hi people,

i really need help , i am new in this things from BIRT Very Happy , and i am trying to do my first API , i used the exemple API from the eclipse webseit but i got the next error. I used the new version from Eclipse and the last Version from BIRT

i will post the error and the code that i used

Thank you


error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException
at org.eclipse.birt.core.framework.Platform.createPlatformLauncher(Platform.java:115)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:74)
at DeDemo.buildReport(DeDemo.java:80)
at DeDemo.main(DeDemo.java:43)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more

CODE:

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.
*/

public class DECreateDynamicTable
{
ReportDesignHandle designHandle = null;
ElementFactory designFactory = null;
StructureFactory structFactory = null;

public static void main( String[] args )
{
try
{
DECreateDynamicTable de = new DECreateDynamicTable();
ArrayList al = new ArrayList();
al.add("OFFICECODE");
al.add("CITY");
al.add("COUNTRY");

de.buildReport(al, "From Offices" );
}
catch ( IOException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch ( SemanticException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

void buildDataSource( ) throws SemanticException
{

OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource(
"Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
dsHandle.setProperty( "odaDriverClass",
"org.eclipse.birt.report.data.oda.sampledb.Driver" );
dsHandle.setProperty( "odaURL", "jdbc:classicmodels:sampledb" );
dsHandle.setProperty( "odaUser", "ClassicModels" );
dsHandle.setProperty( "odaPassword", "" );

designHandle.getDataSources( ).add( dsHandle );

}

void buildDataSet(ArrayList cols, String fromClause ) throws SemanticException
{

OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle.setDataSource( "Data Source" );
String qry = "Select ";
for( int i=0; i < cols.size(); i++){
qry += " " + cols.get(i);
if( i != (cols.size() -1) ){
qry += ",";
}

}
qry += " " + fromClause;

dsHandle.setQueryText( qry );

designHandle.getDataSets( ).add( dsHandle );



}
void buildReport(ArrayList cols, String fromClause ) throws IOException, SemanticException
{


//Configure the Engine and start the Platform
DesignConfig config = new DesignConfig( );

config.setProperty("BIRT_HOME", "C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine");
IDesignEngine engine = null;
try{


Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );

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


SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;



try{
//open a design or a template
designHandle = session.openDesign("c:/tmp/testdeapi.rptdesign");

designFactory = designHandle.getElementFactory( );

buildDataSource();
buildDataSet(cols, fromClause);

TableHandle table = designFactory.newTableItem( "table", cols.size() );
table.setWidth( "100%" );
table.setDataSet( designHandle.findDataSet( "ds" ) );


PropertyHandle computedSet = table.getColumnBindings( );
ComputedColumn cs1 = null;

for( int i=0; i < cols.size(); i++){
cs1 = StructureFactory.createComputedColumn();
cs1.setName((String)cols.get(i));
cs1.setExpression("dataSetRow[\"" + (String)cols.get(i) + "\"]");
computedSet.addItem(cs1);
}


// table header
RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );


for( int i=0; i < cols.size(); i++){
LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );
label1.setText((String)cols.get(i));
CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
cell.getContent( ).add( label1 );
}

// table detail
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
for( int i=0; i < cols.size(); i++){
CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );
data.setResultSetColumn( (String)cols.get(i));
cell.getContent( ).add( data );
}

designHandle.getBody( ).add( table );

// Save the design and close it.

designHandle.saveAs( "c:/temp/sample.rptdesign" ); //$NON-NLS-1$
designHandle.close( );
System.out.println("Finished");
}catch (Exception e){
e.printStackTrace();
}

}
}



i also add and screen schot

Thank you comunity!!!
Re: APIs error conection [message #699942 is a reply to message #699705] Fri, 22 July 2011 15:31 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you start a new workspace in Eclipse and import the attached
project? Make sure to unzip it first and when it is imported update the
build path to point at the jars from the birt
3.7runtime/reportengine/lib jars.

Jason

On 7/22/2011 3:01 AM, richard wrote:
> Hi people,
>
> i really need help , i am new in this things from BIRT :d , and i am trying to do my first API , i used the exemple API from the eclipse webseit but i got the next error. I used the new version from Eclipse and the last Version from BIRT
>
> i will post the error and the code that i used
>
> Thank you
>
> error:
> Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException
> at org.eclipse.birt.core.framework.Platform.createPlatformLauncher(Platform.java:115)
> at org.eclipse.birt.core.framework.Platform.startup(Platform.java:74)
> at DeDemo.buildReport(DeDemo.java:80)
> at DeDemo.main(DeDemo.java:43)
> Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 4 more
>
> CODE:
>
> 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.
> */
>
> public class DECreateDynamicTable
> {
> ReportDesignHandle designHandle = null;
> ElementFactory designFactory = null;
> StructureFactory structFactory = null;
>
> public static void main( String[] args )
> {
> try
> {
> DECreateDynamicTable de = new DECreateDynamicTable();
> ArrayList al = new ArrayList();
> al.add("OFFICECODE");
> al.add("CITY");
> al.add("COUNTRY");
>
> de.buildReport(al, "From Offices" );
> }
> catch ( IOException e )
> {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> catch ( SemanticException e )
> {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
>
> void buildDataSource( ) throws SemanticException
> {
>
> OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource(
> "Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
> dsHandle.setProperty( "odaDriverClass",
> "org.eclipse.birt.report.data.oda.sampledb.Driver" );
> dsHandle.setProperty( "odaURL", "jdbc:classicmodels:sampledb" );
> dsHandle.setProperty( "odaUser", "ClassicModels" );
> dsHandle.setProperty( "odaPassword", "" );
>
> designHandle.getDataSources( ).add( dsHandle );
>
> }
>
> void buildDataSet(ArrayList cols, String fromClause ) throws SemanticException
> {
>
> OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds",
> "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
> dsHandle.setDataSource( "Data Source" );
> String qry = "Select ";
> for( int i=0; i< cols.size(); i++){
> qry += " " + cols.get(i);
> if( i != (cols.size() -1) ){
> qry += ",";
> }
>
> }
> qry += " " + fromClause;
>
> dsHandle.setQueryText( qry );
>
> designHandle.getDataSets( ).add( dsHandle );
>
>
>
> }
> void buildReport(ArrayList cols, String fromClause ) throws IOException, SemanticException
> {
>
>
> //Configure the Engine and start the Platform
> DesignConfig config = new DesignConfig( );
>
> config.setProperty("BIRT_HOME", "C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine");
> IDesignEngine engine = null;
> try{
>
>
> Platform.startup( config );
> IDesignEngineFactory factory = (IDesignEngineFactory) Platform
> .createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
> engine = factory.createDesignEngine( config );
>
> }catch( Exception ex){
> ex.printStackTrace();
> }
>
>
> SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
>
>
>
> try{
> //open a design or a template
> designHandle = session.openDesign("c:/tmp/testdeapi.rptdesign");
>
> designFactory = designHandle.getElementFactory( );
>
> buildDataSource();
> buildDataSet(cols, fromClause);
>
> TableHandle table = designFactory.newTableItem( "table", cols.size() );
> table.setWidth( "100%" );
> table.setDataSet( designHandle.findDataSet( "ds" ) );
>
>
> PropertyHandle computedSet = table.getColumnBindings( );
> ComputedColumn cs1 = null;
>
> for( int i=0; i< cols.size(); i++){
> cs1 = StructureFactory.createComputedColumn();
> cs1.setName((String)cols.get(i));
> cs1.setExpression("dataSetRow[\"" + (String)cols.get(i) + "\"]");
> computedSet.addItem(cs1);
> }
>
>
> // table header
> RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );
>
>
> for( int i=0; i< cols.size(); i++){
> LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );
> label1.setText((String)cols.get(i));
> CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
> cell.getContent( ).add( label1 );
> }
>
> // table detail
> RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
> for( int i=0; i< cols.size(); i++){
> CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
> DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );
> data.setResultSetColumn( (String)cols.get(i));
> cell.getContent( ).add( data );
> }
>
> designHandle.getBody( ).add( table );
>
> // Save the design and close it.
>
> designHandle.saveAs( "c:/temp/sample.rptdesign" ); //$NON-NLS-1$
> designHandle.close( );
> System.out.println("Finished");
> }catch (Exception e){
> e.printStackTrace();
> }
>
> }
> }
>
>
>
> i also add and screen schot
>
> Thank you comunity!!!
  • Attachment: APIs.zip
    (Size: 43.63KB, Downloaded 407 times)
Previous Topic:Setting a data base role
Next Topic:Connecting BIRT to Remote MySQL Server
Goto Forum:
  


Current Time: Thu Apr 25 11:34:13 GMT 2024

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

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

Back to the top