BIRT standalone API

Hello,
please help: I'd like to make a simple Java program that calls the BIRT reporting API. I use Eclipse 3.2.1 as programming platform. It seems as the ReportEngine can not be instantiated. Here the code snippet (as seen on Eclipse BIRT example page "http://wiki.eclipse.org/index.php/Simple_Execute"):

...
static void executeReport() throws EngineException
{
 HashMap<String, Integer> parameters = new HashMap<String, Integer>();

 String name = "Top Count";
 Integer pvalue = new Integer(4);
 parameters.put(name, pvalue);
 
 IReportEngine engine=null;
 EngineConfig config = null;
 try{
 
  //Configure the Engine and start the Platform
  config = new EngineConfig( );
  config.setEngineHome( "D:/birt-runtime-2_1_1/ReportEngine" );
  //set log config using ( null, Level ) if you do not want a log file
  //config.setLogConfig("c:/birt/logs", Level.FINE);
 
  Platform.startup( config );
  IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
  engine = factory.createReportEngine(config);
....

Program exits in the last line (factory.createReportEngine(config); ) with following error:
"
java.lang.NullPointerException
      at reporting.MyClass.executeReport(MyClass.java:41)
      at reporting.MyClass.main(MyClass.java:118)
java.lang.NullPointerException
      at reporting.MyClass.executeReport(MyClass.java:58)
      at reporting.MyClass.main(MyClass.java:118)
..."

My BIRT report API is under "D:/birt-runtime-2_1_1". In the project properties, I added the reference to library files "org.eclipse.birt.core_2.1.1_v20060926-0959.jar" and "org.eclipse.birt.report.engine_2.1.1_v20060926-0959.jar" from the folder "D:/birt-runtime-2_1_1/ReportEngine/plugins" to my java build path. I guess that this is a project configuration matter rather than something else.
Any hints are highly welcome...
zaratinAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CetusMODConnect With a Mentor Commented:
Closed, 250 points refunded.
CetusMOD
Community Support Moderator
0
 
girionisCommented:
Are you sure thte platform is started properly?

Try this

try {
        Platform.startup(config);
    }
    catch (BirtException e) {
        throw new ReportingSystemException("Could not start the platform",
e);
    }
0
 
zaratinAuthor Commented:
Hello girionis, thanks for your answer. I tried he following:

...
            try {
                     Platform.startup(config);
                 }
            catch (BirtException e) {
                      throw new IllegalArgumentException("Could not start the platform",e);
        
                }
...

(I could not figure out which package contains ReportingSystemException). Anyway, the try block does not throw an exception. However, the factory object is still null at

...
                     engine = factory.createReportEngine(config);
...

implying that creation of the factory in the previous line

...
                     IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
...

did not succeed.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
girionisCommented:
Hmm.. Can you make sure that the BIRT runtime is properly installed? Check that you also have (excpet the jar files) the extensions (plug-ins) and the drivers. Have you also configured the JDBC drivers? Also have a look here: http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php and see if that helps at all.
0
 
zaratinAuthor Commented:
Hello girionis,
after hours of digging in the net, eventually I've found out what the problem was: all .jar files from %BIRT_HOME%/lib (in my case "D:/birt-runtime-2_1_1/ReportEngine/lib") need to be included in Java build path of the project. After doing so, ReportEngine was instantiated, but another problem emerged:

"...
noClassDefinitionFound for org/w3c/Tidy
..."

which I resolved by putting the Tidy.jar (from SourceForge.net) into the %BIRT_HOME%/lib directory and including it into Java build path as well. Now everything is working fine.
0
 
girionisCommented:
Nice to hear you got it solved :)

Please ask a moderator to PAQ this question and refund the points to you.
0
 
zaratinAuthor Commented:
Hello girionis,
I'm afraid I have to get back to you again. It seems that everything works fine with hello_world.rptdesign file (no database connection). If I try to run one of the reports that connect to a database I get the following exception:

"...
java.lang.NullPointerException
      at org.eclipse.birt.report.model.elements.OdaDataSource.setIntrinsicProperty(OdaDataSource.java:201)
      at org.eclipse.birt.report.model.core.DesignElement.setProperty(DesignElement.java:1218)
      at org.eclipse.birt.report.model.core.DesignElement.setProperty(DesignElement.java:1188)
      at org.eclipse.birt.report.model.parser.DesignParseState.setProperty(DesignParseState.java:99)
      at org.eclipse.birt.report.model.parser.OdaDataSourceState.parseODADataSourceExtensionID(OdaDataSourceState.java:167)
      at org.eclipse.birt.report.model.parser.OdaDataSourceState.parseAttrs(OdaDataSourceState.java:82)
      at org.eclipse.birt.report.model.parser.ModuleParserHandler.startElement(ModuleParserHandler.java:145)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:878)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
      at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
      at org.eclipse.birt.report.model.parser.ModuleReader.readModule(ModuleReader.java:90)
      at org.eclipse.birt.report.model.parser.DesignReader.read(DesignReader.java:90)
      at org.eclipse.birt.report.model.core.DesignSession.openDesign(DesignSession.java:278)
      at org.eclipse.birt.report.model.api.SessionHandle.openDesign(SessionHandle.java:291)
      at org.eclipse.birt.report.engine.parser.ReportParser.getDesignHandle(ReportParser.java:161)
      at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:243)
      at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:191)
      at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:125)
      at org.eclipse.birt.report.engine.api.impl.ReportEngine.openReportDesign(ReportEngine.java:224)
      at viewtest2.viewtest2.executeReport(viewtest2.java:59)
      at viewtest2.viewtest2.main(viewtest2.java:121)
..."

It seems to me that JDBC drivers are not configured properly. You mentioned that they have to be configured too. How can I do that?
0
 
zaratinAuthor Commented:
Hello girionis,
just found out that the new runtime version (2.2.0 M2) fixes the problem. Thanks for your assistance.
0
 
girionisCommented:
Hello zaratin, sorry for the late reply, I wasn't available during the weekend.. Glad you found the solution yourself. If you need more help let me know :)
0
 
girionisCommented:
I agree and I believe a PAQ/Refund is more appropriate.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.