Solved

BIRT standalone API

Posted on 2006-11-23
11
2,376 Views
Last Modified: 2013-11-18
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...
0
Comment
Question by:zaratin
  • 5
  • 4
11 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 18003001
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
 

Author Comment

by:zaratin
ID: 18006409
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
 
LVL 35

Expert Comment

by:girionis
ID: 18006477
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
 

Author Comment

by:zaratin
ID: 18007743
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
 
LVL 35

Expert Comment

by:girionis
ID: 18007805
Nice to hear you got it solved :)

Please ask a moderator to PAQ this question and refund the points to you.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:zaratin
ID: 18008840
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
 

Author Comment

by:zaratin
ID: 18017662
Hello girionis,
just found out that the new runtime version (2.2.0 M2) fixes the problem. Thanks for your assistance.
0
 
LVL 35

Expert Comment

by:girionis
ID: 18017700
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
 
LVL 35

Expert Comment

by:girionis
ID: 18034930
I agree and I believe a PAQ/Refund is more appropriate.
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 18059313
Closed, 250 points refunded.
CetusMOD
Community Support Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now