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)
BIRT 2.1.1: Can not start the design engine.
Natty77
Hi,
I am trying to create BIRT report using the BIRT API's. But when I am running the code I am getting "Can not start the design engine." error.
Here is the code
ReportBuild : This code will create a report and add a grid and label to the report.
import org.eclipse.birt.report.engine.api.ReportEngine;
import org.eclipse.birt.report.model.api.CellHandle;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignEngine;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.GridHandle;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.RowHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
public class ReportBuild {
public static void ReportBuild() {
OpenReport op = new OpenReport();
ReportDesignHandle design = null;
design = op.OpenReport("null");
//Instantiate an element factory.
ElementFactory factory = design.getElementFactory();
try{
// Create a grid element with 2 columns and 1 row
GridHandle grid = factory.newGridItem("New grid", 2, 1);
// Set a simple property on the grid, the width.
grid.setWidth("50%");
// Create a new label and set its properties.
LabelHandle label = factory.newLabel("Hello label");
label.setText("Hello world");
// Get the first row of the grid.
RowHandle row = (RowHandle) grid.getRows().get(0);
// Add the label to the second cell in the row.
CellHandle cell =(CellHandle)row.getCells().get(1);
cell.getContent().add(label);
// Get the body slot. Add the grid to the end of the slot.
design.getBody().add(grid);
}catch (Exception e){
//Handle any exception.
}
}
public static void main( String[] args ){
ReportBuild();
System.out.println("Finished");
}
}
OpenReport : This code will open a report whose name is passed or create a new one if null is passed.
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.ReportEngine;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignEngine;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
public class OpenReport {
// Create a handle for an existing report design.
private ReportDesignHandle design = null;
// Create a design engine configuration object.
private DesignConfig dConfig = new DesignConfig();
public ReportDesignHandle OpenReport(String rptName) {
if (rptName.equalsIgnoreCase("null")) {
createReport();
} else {
dConfig.setConfigurationVariable("BIRT_HOME", "E:/Natraj/birt-runtime-2_1_1/ReportEngine");
DesignEngine dEngine = new DesignEngine(dConfig);
// Create a session handle, using the system locale.
SessionHandle session = dEngine.newSessionHandle(null);
try {
design = session.openDesign(rptName);
} catch (Exception e) {
System.err.println("Report " + rptName
+ " not opened!nReason is " + e.toString());
return null;
}
}
return design;
}
private void createReport(){
dConfig.setConfigurationVariable("BIRT_HOME", "E:/Natraj/birt-runtime-2_1_1/ReportEngine");
DesignEngine dEngine = new DesignEngine(dConfig);
SessionHandle session = dEngine.newSessionHandle(null);
design = session.createDesign();
}
}
Find more posts tagged with
Comments
There are no comments yet