Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[birt-report-engine-dev] Report Engine API Error

I have just started using BIRT. Apologies if this is the wrong forum for questions - if so where do I go for help? In the mean time...

 

I have successfully created some reports and would like to use the Report Engine API. My simple Report Engine test code is below.

 

When I run it an exception is thrown at this line

 

                  IReportEngine engine = factory.createReportEngine(config);

 

The exception is

 

java.lang.NullPointerException

      at com.nscorp.cd.report.Reporter.go(Reporter.java:28)

      at com.nscorp.cd.report.Reporter.main(Reporter.java:54)

 

Following the report engine docs published on the Eclipse website I think I've setup everything correctly, JDBC drivers etc.

 

Any help would be appreciated...

 

TIA

 

package com.nscorp.cd.report;

 

import java.io.File;

import java.io.FileInputStream;

import java.util.logging.Level;

 

import org.eclipse.birt.core.framework.Platform;

import org.eclipse.birt.report.engine.api.EngineConfig;

import org.eclipse.birt.report.engine.api.EngineException;

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.IRunTask;

 

public class Reporter {

      public void go() {

            try {

                  // Configure the Engine and start the Platform

                  EngineConfig config = new EngineConfig();

                  config.setEngineHome("C:/development/applications/reporting/BIRT/birt-runtime-2_1_1/ReportEngine");

                  // set log config using ( null, Level ) if you do not want a log

                  // file

                  config.setLogConfig("c:/tmp/logs", Level.FINE);

 

                  Platform.startup(config);

                  IReportEngineFactory factory = (IReportEngineFactory) Platform

                              .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);

                  IReportEngine engine = factory.createReportEngine(config);

                  engine.changeLogLevel(Level.WARNING);

 

                  IReportRunnable design = engine.openReportDesign(new FileInputStream(

                        new File( "C:/development/projects/ExecDash/EDApplicationV4/src/reports/HeadCount.rptdesign" ) ) );

 

                  // Create task to run the report - use the task to execute the

                  // report and save to disk.

                  IRunTask task = engine.createRunTask(design);

 

                  // run the report and destroy the engine

                  task.run("c:/tmp/Headcount.rptdocument");

 

                  task.close();

 

                  engine.shutdown();

                  Platform.shutdown();

 

            } catch (Exception ex) {

                  ex.printStackTrace();

            }

      }

 

      public static void main(String args[]) {

            try {

                  Reporter r = new Reporter();

                  r.go();

            } catch (Throwable t) {

                  t.printStackTrace();

            }

      }

}

 

 


Back to the top