Report engine / run and render problem [message #645994] |
Tue, 21 December 2010 14:10 |
Don Wood Messages: 32 Registered: February 2010 Location: Pennsylvania |
Member |
|
|
I have an Enterprise project in Rational using BIRT. Some reports will be produced using the viewer; other reports will be produced using the Report Engine API. Our environment is set up as follows:
An EAR project - this contains coreapi.jar, engineapi.jar, js.jar, and modelapi.jar.
A web project which contains our report design files plus the JSP pages which then have the birt viewer tags. This project contains a Webcontent/WEB-INF/lib directory which contains coreapi.jar, engineapi.jar, js.jar, and modelapi.jar. Additionally, it contains the platform/plugins directory which is part of the BIRT engine runtime.
A utility project which contains our action classes and business logic. It is from here that a singleton is used to start the report engine and then produce reports via the Report Engine API.
Does BIRT support this type of a setup? Everything worked fine from the viewer. It was only when attempting to produce a report using the API when errors started appearing. Where our confusion lies is what jars need to be in which project. At one point, I was receiving a NoClassDefFoundError on IScriptStyle. This class (IScriptStyle) exists only in a JAR in the plugins folder so I'm thinking that the run task (which is in our utility project) can't find the platform/plugins folder in the web project...even though this is where the PlatformContext was set when the engine was created. I then copied the plugins folder to the EAR project and then created a dependency between the utility project and the EAR project but this then produced the error below.
Exception created : java.lang.IncompatibleClassChangeError: org/eclipse/birt/report/model/metadata/MetaDataDictionary.in tializeExtension()V
at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.init ialize(DesignEngineImpl.java:107)
at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.newS essionHandle(DesignEngineImpl.java:155
As a point of interest, I created a simple JSP page (found below) with scriptlet code to instantiate the report engine, then run and render the test.rptdesign found in the birt runtime. I placed this JSP page in my web project (mentioned above). When navigating to this JSP page, the report worked.
Could anyone provide some assistance?
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<%@ page import ="org.eclipse.birt.core.framework.IPlatformContext"%>
<%@ page import ="org.eclipse.birt.core.framework.Platform"%>
<%@ page import ="org.eclipse.birt.core.framework.PlatformServletContext"% >
<%@ page import ="org.eclipse.birt.report.engine.api.EngineConfig"%>
<%@ page import ="org.eclipse.birt.report.engine.api.IReportEngine"%>
<%@ page import ="org.eclipse.birt.report.engine.api.IReportEngineFactory"% >
<%@ page import ="org.eclipse.birt.report.engine.api.IReportRunnable"%>
<%@ page import ="org.eclipse.birt.report.engine.api.IRunAndRenderTask"%>
<%@ page import ="org.eclipse.birt.report.engine.api.HTMLRenderOption"%>
<%@ page import ="java.io.*"%>
<%
EngineConfig engineConfig =new EngineConfig( );
IReportEngine engine;
engineConfig.setBIRTHome("");
//ServletContext newCtx = request.getContextPath().getContext("/MPMSBIRTViewer/WEB-INF/ ");
//ServletContext newCtx = request.getSession().getServletContext();
IPlatformContext iPlatformContext = new PlatformServletContext( application );
String myCtx = iPlatformContext.getPlatform();
engineConfig.setPlatformContext( iPlatformContext );
Platform.startup( engineConfig );
IReportEngineFactory factory =
(IReportEngineFactory)Platform.
createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_EN GINE_FACTORY );
engine = factory.createReportEngine( engineConfig );
//Open the report design
String path = application.getRealPath("/") + File.separator + "test.rptdesign";
System.out.println(path);
System.out.println("Realpath is: " + application.getRealPath("/"));
IReportRunnable design = engine.openReportDesign(path);
//Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat("pdf");
options.setOutputFileName(application.getRealPath("/") + File.separator + "test.pdf");
task.setRenderOption(options);
task.run();
task.close();
%>
</head>
<body>
</body>
</html>
[Updated on: Tue, 21 December 2010 14:37] Report message to a moderator
|
|
|
Re: Report engine / run and render problem [message #646020 is a reply to message #645994] |
Tue, 21 December 2010 15:31 |
|
Don,
Are you calling the api from the same project that contains the WebViewer?
Jason
On 12/21/2010 9:10 AM, Don wrote:
> I have an Enterprise project in Rational using BIRT. Some reports will
> be produced using the viewer; other reports will be produced using the
> Report Engine API. Our environment is set up as follows:
>
> An EAR project - this contains coreapi.jar, engineapi.jar, js.jar, and
> modelapi.jar.
>
> A web project which contains our report design files plus the JSP pages
> which then have the birt viewer tags. This project contains a
> Webcontent/WEB-INF/lib directory which contains coreapi.jar,
> engineapi.jar, js.jar, and modelapi.jar. Additionally, it contains the
> platform/plugins directory which is part of the BIRT engine runtime.
>
> A utility project which contains our action classes and business logic.
> It is from here that a singleton is used to start the report engine and
> then produce reports via the Report Engine API.
>
> Does BIRT support this type of a setup? Everything worked fine from the
> viewer. It was only when attempting to produce a report using the API
> when errors started appearing. Where our confusion lies is what jars
> need to be in which project. At one point, I was receiving a
> NoClassDefFoundError on IScriptStyle. This class (IScriptStyle) exists
> only in a JAR in the plugins folder so I'm thinking that the run task
> (which is in our utility project) can't find the platform/plugins folder
> in the web project...even though this is where the PlatformContext was
> set when the engine was created. I then copied the plugins folder to the
> EAR project and then created a dependency between the utility project
> and the EAR project but this then produced the error below.
>
> Exception created : java.lang.IncompatibleClassChangeError:
> org/eclipse/birt/report/model/metadata/MetaDataDictionary.in
> tializeExtension()V
> at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.init
> ialize(DesignEngineImpl.java:107)
> at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.newS
> essionHandle(DesignEngineImpl.java:155
>
> As a point of interest, I have another project that was originally
> created as our viewer project. I created a simple JSP page (found below)
> with scriptlet code to instantiate the report engine, then run and
> render the test.rptdesign found in the birt runtime. This worked. But if
> I copy this JSP page to my web project, it fails.
>
> Could anyone provide some assistance?
>
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
> pageEncoding="ISO-8859-1"%>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> <title>Insert title here</title>
>
> <%@ page import ="org.eclipse.birt.core.framework.IPlatformContext"%>
> <%@ page import ="org.eclipse.birt.core.framework.Platform"%>
> <%@ page import
> ="org.eclipse.birt.core.framework.PlatformServletContext"% >
> <%@ page import ="org.eclipse.birt.report.engine.api.EngineConfig"%>
> <%@ page import ="org.eclipse.birt.report.engine.api.IReportEngine"%>
> <%@ page import
> ="org.eclipse.birt.report.engine.api.IReportEngineFactory"% >
> <%@ page import ="org.eclipse.birt.report.engine.api.IReportRunnable"%>
> <%@ page import ="org.eclipse.birt.report.engine.api.IRunAndRenderTask"%>
> <%@ page import ="org.eclipse.birt.report.engine.api.HTMLRenderOption"%>
> <%@ page import ="java.io.*"%>
>
>
> <%
> EngineConfig engineConfig =new EngineConfig( );
> IReportEngine engine;
> engineConfig.setBIRTHome("");
> //ServletContext newCtx =
> request.getContextPath().getContext("/MPMSBIRTViewer/WEB-INF/ ");
>
> //ServletContext newCtx = request.getSession().getServletContext();
>
> IPlatformContext iPlatformContext = new PlatformServletContext(
> application );
>
> String myCtx = iPlatformContext.getPlatform();
> engineConfig.setPlatformContext( iPlatformContext );
>
> Platform.startup( engineConfig );
> IReportEngineFactory factory = (IReportEngineFactory)Platform.
> createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_EN
> GINE_FACTORY );
> engine = factory.createReportEngine( engineConfig );
>
> //Open the report design
> String path = application.getRealPath("/") + File.separator +
> "test.rptdesign";
> System.out.println(path);
> System.out.println("Realpath is: " + application.getRealPath("/"));
> IReportRunnable design = engine.openReportDesign(path);
> //Create task to run and render the report,
> IRunAndRenderTask task = engine.createRunAndRenderTask(design);
> HTMLRenderOption options = new HTMLRenderOption();
> options.setOutputFormat("pdf");
> options.setOutputFileName(application.getRealPath("/") + File.separator
> + "test.pdf");
> task.setRenderOption(options);
> task.run();
> task.close();
>
>
> %>
>
> </head>
> <body>
>
> </body>
> </html>
>
|
|
|
|
Re: Report engine / run and render problem [message #646067 is a reply to message #646058] |
Tue, 21 December 2010 18:53 |
|
If you are using the webviewer and the jsp page you posted is used in
the same web project you should not have to start the platform again.
Can you try commenting out the startup?
Jason
On 12/21/2010 1:31 PM, Don wrote:
> Jason,
>
> Yes, our web project contains both the viewer (in the lib folder) and
> the API in the platform/plugins folder.
> When a user accesses a JSP page (found in the web project), a servlet
> calls business classes that are located in the utility project. These
> business classes instantiate the report engine if necessary (a
> singleton). This much works as expected. Business classes then attempt
> to run and render a BIRT report design (which is back in the web project).
>
> We initially tried to have the viewer in its own project but we were
> running into NoClassDefFoundErrors when attempting to use the API method
> of producing reports.
>
> Thanks for your help. Let me know if you need any other information.
|
|
|
Powered by
FUDForum. Page generated in 0.03087 seconds