BIRT 3.7 in a GWT Application [message #756006] |
Thu, 10 November 2011 13:05 |
Todd Blackwell Messages: 5 Registered: November 2011 |
Junior Member |
|
|
Hi,
I'm trying to create a GWT application that uses BIRT 3.7.1 to create PDF reports. My Eclipse version is Indigo (just downloaded it yesterday), and I have the latest version of the GWT plug-in. Right now, all I'm trying to do is put the code that creates a report into the init method of a servlet, and have that servlet initialize on application startup. The container I'm using to host the application is the dev mode server that comes with the GWT plug-in, which is really just a Jetty instance behind the scenes. Unfortunately, when the application starts up I get the following error from the BIRT code:
org.eclipse.birt.report.engine.api.EngineException: Error happened while running the report.
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:196)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at com.blackwell.gwt.birt.server.BirtServlet.init(BirtServlet.java:70)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:463)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:667)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:500)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1055)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:804)
at com.google.gwt.dev.DevMode.main(DevMode.java:309)
Caused by: java.lang.NullPointerException
at org.eclipse.datatools.connectivity.oda.spec.manifest.ResultExtensionExplorer.addAllExtensions(ResultExtensionExplorer.java:541)
at org.eclipse.datatools.connectivity.oda.spec.manifest.ResultExtensionExplorer.<init>(ResultExtensionExplorer.java:122)
at org.eclipse.datatools.connectivity.oda.spec.manifest.ResultExtensionExplorer.getInstance(ResultExtensionExplorer.java:86)
at org.eclipse.birt.data.engine.impl.DataEngineImpl.getValidationContext(DataEngineImpl.java:764)
at org.eclipse.birt.data.engine.impl.OdaDataSetRuntime.<init>(OdaDataSetRuntime.java:56)
at org.eclipse.birt.data.engine.impl.DataSetRuntime.newInstance(DataSetRuntime.java:349)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.configureDataSetCache(PreparedDataSourceQuery.java:231)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:171)
at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(PreparedOdaDSQuery.java:145)
at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:620)
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:152)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
at org.eclipse.birt.report.engine.executor.ExtendedGenerateExecutor.executeQueries(ExtendedGenerateExecutor.java:205)
at org.eclipse.birt.report.engine.executor.ExtendedGenerateExecutor.execute(ExtendedGenerateExecutor.java:65)
at org.eclipse.birt.report.engine.executor.ExtendedItemExecutor.execute(ExtendedItemExecutor.java:62)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180)
... 23 more
Here's the code I'm attempting to execute:
@Override
public void init(ServletConfig config) throws ServletException
{
IReportEngine engine = null;
EngineConfig engineConfig = null;
try
{
engineConfig = new EngineConfig();
engineConfig.setLogConfig("/nethome/eblack04/logs", Level.FINEST);
Platform.startup(engineConfig);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(engineConfig);
IReportRunnable design = null;
// Open the report design
design = engine.openReportDesign("/nethome/eblack04/AnomalyGraphTemplate.rptdesign");
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName("/nethome/eblack04/AnomalyGraphTemplate.pdf");
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
engine.destroy();
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
Platform.shutdown();
}
}
It's definitely nothing fancy, and the funny thing is that I've also created another class that runs the same code from the command line, and it works! Even when I run it from within Eclipse, which is done by right-clicking on the class I wrote and selecting Run As...->Java Application. Here's the command line class I wrote for completeness:
public class ReportTest
{
private void createReport()
{
IReportEngine engine = null;
EngineConfig engineConfig = null;
try
{
engineConfig = new EngineConfig();
engineConfig.setLogConfig("/nethome/eblack04/logs", Level.FINEST);
Platform.startup(engineConfig);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(engineConfig);
IReportRunnable design = null;
// Open the report design
design = engine.openReportDesign("/nethome/eblack04/AnomalyGraphTemplate.rptdesign");
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName("/nethome/eblack04/AnomalyGraphTemplate.pdf");
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
engine.destroy();
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
Platform.shutdown();
}
}
public static void main(String[] args)
{
ReportTest tester = new ReportTest();
tester.createReport();
}
}
It's the same exact code that's in the servlet's init method, and this runs just fine. This has to mean that the problem lies somewhere within the Jetty instance GWT is using to run the code, which seems to indicate that it is some sort of classloader issue. Is my assumption correct? If so, has anybody else run across this yet? If so, has anybody found a solution to it? We absolutely need a solution to this as this code is being used in a formal project for a customer, and we'd like to migrate to 3.7.1, but can't until we find a solution to this as the embedded Jetty instance that comes with the GWT plug-in is our main development container. If we can't get the code to work there, then there's no way we can get a sign off on the code to go to production. Any help would be greatly appreciated.
Thanks,
Todd
|
|
|
|
|
Re: BIRT 3.7 in a GWT Application [message #756045 is a reply to message #756016] |
Thu, 10 November 2011 16:09 |
Todd Blackwell Messages: 5 Registered: November 2011 |
Junior Member |
|
|
Okay, after playing around a little more today, I've found a workaround, and it really underlines that the problem I outlined is indeed a classloader issue. The solution all started when I took a closer look at the console output of the GWT application when I started it up. In particular, I kept seeing these types of messages:
[WARN] Server class 'org.eclipse.birt.core.framework.PlatformConfig' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.birt.runtime_3.7.1.v20110913-1734.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.core.runtime.CoreException' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.equinox.common_3.6.0.v20110523.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.core.runtime.spi.IRegistryProvider' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.equinox.registry_3.5.101.R37x_v20110810-1611.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.core.runtime.Platform' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.core.runtime_3.7.0.v20110110.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.osgi.util.NLS' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.datatools.connectivity.oda.util.manifest.ManifestExplorer' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.datatools.connectivity.oda_3.3.2.v201105200920.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.emf.common.util.Enumerator' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.emf.common_2.7.0.v20110905-0902.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.emf.ecore.EObject' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.emf.ecore_2.7.0.v20110905-0902.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.eclipse.emf.ecore.xmi_2.7.0.v20110520-1406.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.apache.batik.css.parser.Parser' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.apache.batik.css_1.6.0.v201011041432.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'org.apache.batik.i18n.Localizable' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/pgpd/users/eblack04/birt-runtime-3_7_1/ReportEngine/lib/org.apache.batik.util_1.6.0.v201011041432.jar' to the web app classpath for this session
For additional info see: file:/goesrapps1/eclipse_3.6.2/plugins/com.google.gwt.eclipse.sdkbundle_2.3.0.r36v201105191508/gwt-2.3.0/doc/helpInfo/webAppClassPath.html
These messages appear because I've created a User Library that points to all the jar files under the birt-runtime-3_7_1/ReportEngine/lib directory, and have added that library to my application classpath instead of directly copying all the jars under the birt-runtime-3_7_1/ReportEngine/lib into my WEB-INF/lib directory. I didn't copy them because I'm developing on the same server that the BIRT runtime is on, so why have them in two places? Because of this, the application went to the system classloader to retrieve the BIRT classes as indicated by the above messages, and this is what caused the exception. The exception went away and the report was correctly generated when I deleted the User Library from my project configuration, and added the BIRT jar files to my WEB-INF/lib directory.
This behavior did not happen with 2.6.2, so there must be some type of classloader change with 3.7.1 that has made it so that the BIRT report engine cannot run if the classes used to generate the reports come from a different classloader than the one used to actually run the code the create the report. This is probably not a bug, but it is something to be aware of when dealing with 3.7.1 in a web application, or any other type of application that could have the same scenario.
Thanks,
Todd
|
|
|
Powered by
FUDForum. Page generated in 0.03427 seconds