Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

BIRT standalone API

Posted on 2006-11-23
11
Medium Priority
?
2,435 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

886 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