Hi All.<br />
I have web application in which used birt. Sometime I have strange exceptions.<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
java.lang.NullPointerException
at
com.trackstudio.app.report.birt.BirtEngine.getBirtEngine(BirtEngine.java:87)
at
com.trackstudio.action.WebReportServlet.doGet(WebReportServlet.java:148)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at
</pre>
<pre class='_prettyXprint _lang-auto _linenums:0'>
package com.trackstudio.app.report.birt;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.IPlatformContext;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.core.framework.PlatformServletContext;
import org.eclipse.birt.report.engine.api.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.ServletContext;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
public class BirtEngine {
private final static String configFile = "birt-config.properties";
private static Properties configProps = new Properties();
private static IReportEngine birtEngine = null;
private static Log log = LogFactory.getLog(BirtEngine.class);
public static synchronized void initBirtConfig() {
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream in = cl.getResourceAsStream(configFile);
configProps.load(in);
in.close();
} catch (IOException e) {
log.error("Exception ", e);
}
}
public static synchronized IReportEngine getBirtEngine(ServletContext sc) {
if (birtEngine == null) {
EngineConfig config = new EngineConfig();
if (configProps != null) {
String logLevel = configProps.getProperty("logLevel");
Level level = Level.OFF;
if ("SEVERE".equalsIgnoreCase(logLevel)) {
level = Level.SEVERE;
} else if ("WARNING".equalsIgnoreCase(logLevel)) {
level = Level.WARNING;
} else if ("INFO".equalsIgnoreCase(logLevel)) {
level = Level.INFO;
} else if ("CONFIG".equalsIgnoreCase(logLevel)) {
level = Level.CONFIG;
} else if ("FINE".equalsIgnoreCase(logLevel)) {
level = Level.FINE;
} else if ("FINER".equalsIgnoreCase(logLevel)) {
level = Level.FINER;
} else if ("FINEST".equalsIgnoreCase(logLevel)) {
level = Level.FINEST;
} else if ("OFF".equalsIgnoreCase(logLevel)) {
level = Level.OFF;
} else if ("ALL".equalsIgnoreCase(logLevel)) {
level = Level.ALL;
}
config.setLogConfig(configProps.getProperty("logDirectory"), level);
}
config.setEngineHome("");
IPlatformContext context = new PlatformServletContext(sc);
config.setPlatformContext(context);
try {
Platform.startup(config);
} catch (BirtException e) {
log.error("Exception ", e);
}
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
birtEngine = factory.createReportEngine(config);
HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig();
emitterConfig.setActionHandler(new HTMLActionHandler());
HTMLServerImageHandler imageHandler = new HTMLServerImageHandler();
emitterConfig.setImageHandler(imageHandler);
config.getEmitterConfigs().put("html", emitterConfig); //$NON-NLS-1$
}
return birtEngine;
}
public static synchronized void destroyBirtEngine() {
if (birtEngine == null) {
return;
}
birtEngine.shutdown();
Platform.shutdown();
birtEngine = null;
}
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
}
</pre>
I found other thread where was discussion this problem.<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/forum/index.php/topic/13290-platform-createfactoryobject-returns-null/page__s__3a2c80e2249a11574d6d5c8b48edd18b'>http://www.birt-exchange.org/org/forum/index.php/topic/13290-platform-createfactoryobject-returns-null/page__s__3a2c80e2249a11574d6d5c8b48edd18b</a><br />
But I want more details detect reason this exception. May be have any way diagnosis this problem.<br />
Thanks.