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 when packaging BIRT 4.3.1 in maven jar-with-dependencies
gberkowitz
<p>I'm trying to package BIRT <strong>4.3.1</strong> in an executable jar using <strong>maven</strong>.
Excerpt from <em>pom.xml</em>:</p><pre class="_prettyXprint"><project [...]> [...] <dependencies> [...] <dependency> <groupId>org.eclipse.birt.runtime</groupId> <artifactId>org.eclipse.birt.runtime</artifactId> <version>4.3.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>com.domain.App</mainClass> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.domain.App</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build></project></pre><p>The main class, <em>App.java</em>:</p><pre class="_prettyXprint">package com.domain;import org.eclipse.birt.core.exception.BirtException;import org.eclipse.birt.report.engine.api.EngineException;import org.eclipse.birt.report.engine.api.IReportEngine;import org.eclipse.birt.report.engine.api.IReportRunnable;public class App { public static void main(String[] args) { try { IReportEngine birtEngine = BirtEngine.getBirtEngine(); IReportRunnable design = birtEngine .openReportDesign("/path/to/file.rptdesign"); } catch (EngineException e) { e.printStackTrace(); } catch (BirtException e) { e.printStackTrace(); } }}</pre><p><em>BirtEngine.java:</em>
</p><pre class="_prettyXprint">package com.domain;import org.eclipse.birt.report.engine.api.EngineConfig;import org.eclipse.birt.report.engine.api.IReportEngine;import org.eclipse.birt.core.framework.Platform;import org.eclipse.birt.core.exception.BirtException;import org.eclipse.birt.report.engine.api.IReportEngineFactory;public class BirtEngine { private static IReportEngine birtEngine = null; public static synchronized IReportEngine getBirtEngine() throws BirtException { if (birtEngine == null) { EngineConfig config = new EngineConfig(); Platform.startup(config); IReportEngineFactory factory = (IReportEngineFactory) Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY); birtEngine = factory.createReportEngine(config); } return birtEngine; }}</pre><p>When I run:</p><pre class="_prettyXprint">...$ exec:java</pre><p>I see:</p><pre class="_prettyXprint">[INFO] BUILD SUCCESSFUL</pre><p>But when I run:</p><pre class="_prettyXprint">...$ mvn compile assembly:single...$ java -jar ./target/Test-1.0-SNAPSHOT-jar-with-dependencies.jar</pre><p>I see:</p><pre class="_prettyXprint">[INFO] BUILD SUCCESSFUL</pre><p>followed by:</p><pre class="_prettyXprint">Exception in thread "main" java.lang.NullPointerException at com.domain.BirtEngine.getBirtEngine(BirtEngine.java:23) at com.domain.App.main(App.java:11)</pre><p>BirtEngine.java:23 is:
birtEngine = factory.createReportEngine(config);
App.java:11 is:
IReportEngine birtEngine = BirtEngine.getBirtEngine();
Why do I get an error when packaging BIRT in a <strong>maven jar-with-dependencies</strong>? What should I do differently?
</p>
Find more posts tagged with
Comments
bmark
<p>I have the same Issue with 3.7.x</p>
JFreeman
<p>Take a look at this DevShare on using BIRT with Maven: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/925-using-birt-430-with-maven/'>http://developer.actuate.com/community/forum/index.php?/files/file/925-using-birt-430-with-maven/</a></p>
;
<p> </p>
<p>Hopefully that will help get you further.</p>