Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
NullPointerException in ReportEngine class
JayP
Hi,
I'm trying to develop and deploy a custom Web based BIRT report using BIRT ReportEngine API 2_6_0 and getting the following error while trying to run the web application on JBoss 4.2 app server. I also tried with BIRT ReportEngine API 2_5_2 and get the exact same error.
12:25:33,861 ERROR [STDERR] java.lang.NullPointerException
12:25:33,861 ERROR [STDERR] at org.eclipse.birt.report.engine.api.impl.ReportEngine$EngineExtensionManager.<init>(ReportEngine.java:813)
12:25:33,861 ERROR [STDERR] at org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEngine.java:110)
The error is encountered in org.eclipse.birt.report.engine.api.impl.ReportEngine class at the following line:
IExtensionRegistry registry = Platform.getExtensionRegistry( );
Here, the registry value is null.
Following is the sample piece of my code to get the IReportEngine object. I call this code from a Servlet.
private static IReportEngine birtEngine = null;
EngineConfig config = new EngineConfig();
config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, Thread.currentThread().getContextClassLoader());
config.setBIRTHome("C:/birt-runtime-2_6_0/ReportEngine");
IPlatformContext context = new PlatformServletContext( sc );
config.setPlatformContext( context );
try
{
Platform.startup( config );
}
catch ( BirtException e )
{
e.printStackTrace( );
}
IReportEngineFactory factory = null;
try {
factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
} catch ( Exception e )
{
if(factory == null) {
System.out.println("Null factory");
} else {
System.out.println("Factory not null");
}
e.printStackTrace();
}
try {
birtEngine = factory.createReportEngine( config );
} catch ( Exception e )
{
if(birtEngine == null) {
Platform.shutdown();
System.out.println("Null BirtEngine object");
} else {
System.out.println("birtEngine not null");
}
e.printStackTrace();
}
Any help would be really appreciated.
Find more posts tagged with
Comments
JasonW
Where do you have the plugins in this app?
Jason
JayP
Hi Jason,
Thanks for your reply. The problem has been solved. My JBoss server was probably having multiple versions of birt runtime jars, which probably happened during trial and error and was causing the problem. Later I cleaned up my JBoss default server and started fresh by putting the birt runtime jars to the following places in my web application:
1. birt_runtime/lib jars -> WEB-INF/lib
2. birt_runtime/plugins -> WEB-INF/platform/plugins
3. birt_runtime/configuration -> WEB-INF/platform/configuration
And everyting started working. But there was some problem with 2.6.0 version. It required the following jars from the Design Engine/plugins to the platform/plugins of my web application (these jars are missing from the 2.6.0 version). Finally I'm able to generate my web report using RE API.
org.eclipse.datatools.sqltools.sql_1.0.0.v200906022302.jar
org.eclipse.datatools.sqltools.sqlbuilder_1.0.1.v201005260600.jar
org.eclipse.datatools.sqltools.sqleditor_1.0.1.v201005130745.jar
Thanks.
JayP
Jason,
Could your recommend any good book about building custom BIRT report using RE API for web application.
Thanks,
JayP
JasonW
Can you log a bug for the missing runtime jars?
For a book take a look here:
==Shameless Plug==
http://www.eclipse.org/birt/phoenix/birthelp.php#books
We have a second edition out and we are currently working on a 3rd edition.
====
You may also want to look at John Ward's book
https://www.packtpub.com/practical-data-analysis-reporting-with-birt/book
Not sure if you have seen this but here is a wiki page on setting up web app with the report engine.
http://wiki.eclipse.org/Servlet_Example_(BIRT)_2.1
http://wiki.eclipse.org/Integration_Examples_(BIRT)
There are several examples of code here(birt exchange) on the devshare. There are also webinars on the DE, CE, and RE apis.
Jason
JayP
Jason,
After doing some tests without these jars, I found my web application works fine. So please disregard about the missing jars problem in 2.6.0 version. But I still get the following Exception even though my report runs fine. I use Oracle database driver and copied the 'classes12.jar' in /WEB-INF/lib folder of my web app. I use the following code to connect to the Oracle datasource. Would appreciate any help on this.
CODE:
OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource("Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
dsHandle.setProperty( "odaDriverClass", "oracle.jdbc.driver.OracleDriver" );
dsHandle.setProperty( "odaURL", "jdbc:oracle:oci:
@databasename"
; );
dsHandle.setProperty( "odaUser", "userid" );
dsHandle.setProperty( "odaPassword", "password" );
designHandle.getDataSources().add( dsHandle );
EXCEPTION:
2010-08-04 11:58:56,312 ERROR [STDERR] Aug 4, 2010 11:58:56 AM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
INFO: Found JDBC driverinfo extension: driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null
2010-08-04 11:58:56,312 ERROR [STDERR] Aug 4, 2010 11:58:56 AM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
INFO: Found JDBC driverinfo extension: driverClass=org.eclipse.birt.report.data.oda.sampledb.Driver, connectionFactory=org.eclipse.birt.report.data.oda.sampledb.SampleDBJDBCConnectionFactory
2010-08-04 11:58:56,312 ERROR [STDERR] Aug 4, 2010 11:58:56 AM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadAndRegisterDriver
INFO: Loading JDBC driver class: oracle.jdbc.driver.OracleDriver
2010-08-04 11:58:56,344 ERROR [STDERR] Aug 4, 2010 11:58:56 AM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager findDriver
INFO: Driver class not in class path: oracle.jdbc.driver.OracleDriver. Trying to locate driver in drivers directory
2010-08-04 11:58:56,344 ERROR [STDERR] Aug 4, 2010 11:58:56 AM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadExtraDriver
SEVERE: DriverClassLoader failed to load class: oracle.jdbc.driver.OracleDriver
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at org.eclipse.birt.core.framework.URLClassLoader.findClass1(URLClassLoader.java:185)
Thanks for all the helpful information.
JayP
JasonW
The engine is looking for your driver in the jdbc plugin's driver directory. That is the error you are getting. If you do not want to put it there you can specify the drivers directory like:
config.getAppContext().put("OdaJDBCDriverClassPath", "c:/birt/mysql/mysql-connector-java-5.0.4-bin.jar");
Where config is the EngineConfig. If you are using connection profiles there is a property for the driver classpath.
Jason
JayP
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="67066" data-time="1280959554" data-date="04 August 2010 - 03:05 PM"><p>
The engine is looking for your driver in the jdbc plugin's driver directory. That is the error you are getting. If you do not want to put it there you can specify the drivers directory like:<br />
config.getAppContext().put("OdaJDBCDriverClassPath", "c:/birt/mysql/mysql-connector-java-5.0.4-bin.jar");<br />
Where config is the EngineConfig. If you are using connection profiles there is a property for the driver classpath.<br />
<br />
Jason<br /></p></blockquote>
<br />
<br />
Thanks Jason. Both the approaches worked fine. But I like to specify the path through the code vs. copying the jar to the specified directory.<br />
<br />
Thanks,<br />
Jay
JasonW
When you say through code, can you explain a little more?
Jason
JayP
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="67295" data-time="1281583578" data-date="11 August 2010 - 08:26 PM"><p>
When you say through code, can you explain a little more?<br />
<br />
Jason<br /></p></blockquote>
<br />
Jason,<br />
<br />
I have a Java program that initializes the Report engine and that's where I put this line -<br />
<br />
EngineConfig config = new EngineConfig();<br />
config.getAppContext().put("OdaJDBCDriverClassPath", driverPath); <br />
<br />
I read the 'driverPath' from a property file and that way I'm open to change the property file info without making any change to the Java program.<br />
<br />
<br />
<br />
I'm having compilation problem which is related to the files being used from the following two packages:<br />
<br />
org.eclipse.birt.report.utility;<br />
org.eclipse.birt.report.resource;<br />
<br />
I'm trying to import these two packages in one of my JSP pages.<br />
<br />
Could you please tell me which JAR file do I need to add to my project classpath to resolve the compilation problem related to the files from these two packages?<br />
<br />
Thanks for your help.<br />
<br />
JayP
JayP
<blockquote class='ipsBlockquote' data-author="'JayP'" data-cid="67869" data-time="1282946374" data-date="27 August 2010 - 02:59 PM"><p>
Jason,<br />
<br />
I have a Java program that initializes the Report engine and that's where I put this line -<br />
<br />
EngineConfig config = new EngineConfig();<br />
config.getAppContext().put("OdaJDBCDriverClassPath", driverPath); <br />
<br />
I read the 'driverPath' from a property file and that way I'm open to change the property file info without making any change to the Java program.<br />
<br />
<br />
<br />
I'm having compilation problem which is related to the files being used from the following two packages:<br />
<br />
org.eclipse.birt.report.utility;<br />
org.eclipse.birt.report.resource;<br />
<br />
I'm trying to import these two packages in one of my JSP pages.<br />
<br />
Could you please tell me which JAR file do I need to add to my project classpath to resolve the compilation problem related to the files from these two packages?<br />
<br />
Thanks for your help.<br />
<br />
JayP<br /></p></blockquote>
<br />
<br />
Jason,<br />
I could solve this problem by adding viewservlets.jar to my classpath.<br />
<br />
Thanks,<br />
JayP