The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

NullPointerException when packaging BIRT 4.3.1 in maven jar-with-dependencies

<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>
Tagged:

Comments

Sign In or Register to comment.