Solved

BIRT standalone API

Posted on 2006-11-23
11
2,390 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
micro services vs rest web services 16 103
micro services spring boot application error 3 187
spring jars download 1 26
sql import cannot be resolved jsp 3 19
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

776 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