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)
How to integrate BIRT 3.7 Report Engine in a servlet
rpfister
For BIRT 2.6 I integrated the Report Engine in a Servlet like this:
...
EngineConfig config = new EngineConfig();
config.setLogConfig(configProps.getProperty("logDirectory"), level);
config.setEngineHome("");
IPlatformContext context = new PlatformServletContext(sc);
config.setPlatformContext(context);
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
birtEngine = factory.createReportEngine(config);
...
In BIRT 3.7 it doesn't work anymore. Can anybody tell me how to do it for BIRT 3.7?
Thanks for your help or any hints!
Rolf
Find more posts tagged with
Comments
JasonW
This code should still work for BIRT 3.7. For completeness remove the set birt home. Do you have all the jars in runtime download/reportengine/lib in the web-inf/lib directory of your app? Also verify that you do not have a platform directory under web-inf any more.
Jason
PhilippL
I use the same code as Rolf and did what Jason proposed, i.e. removed the set birt home, copied all jars from reportengine/lib to web-inf/lib, deleted the platform directory in web-inf. But while starting Tomcat 6 I get the following error:
19.07.2011 16:41:16 com.dynelytics.st.web.birt.BirtEngine getBirtEngine
SCHWERWIEGEND: error.CannotStartupOSGIPlatform
org.eclipse.birt.core.exception.BirtException: error.CannotStartupOSGIPlatform
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:92)
at com.dynelytics.st.web.birt.BirtEngine.getBirtEngine(BirtEngine.java:74)
at com.dynelytics.st.web.birt.BirtInitializationPlugin.init(BirtInitializationPlugin.java:38)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4733)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3460)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1357)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1649)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1658)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1658)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1638)
at java.lang.Thread.run(Thread.java:662)
What's missing?
Thanks!
Philipp
JasonW
Does this app only have birt jars in the web-inf/lib? I have seen this error when two versions of one of the jars is in the classpath.
Jason
PhilippL
There are other jars in web-inf/lib. I've found the following jars with different versions and deleted the first (older) one:
com.ibm.icu_4.2.1.v20100412.jar / com.ibm.icu_4.4.2.v20110208.jar
commons-logging-1.0.4.jar / commons-logging.jar
javax.wsdl_1.5.1.v201005080630.jar / javax.wsdl_1.5.1.v201012040544.jar
org.apache.commons.codec_1.3.0.v20100518-1140.jar / org.apache.commons.codec_1.3.0.v201101211617.jar
org.eclipse.emf.common_2.6.0.v20100914-1218.jar / org.eclipse.emf.common_2.7.0.v20110527-1609.jar
org.eclipse.emf.ecore.xmi_2.5.0.v20100521-1846.jar / org.eclipse.emf.ecore.xmi_2.7.0.v20110520-1406.jar
org.eclipse.emf.ecore_2.6.1.v20100914-1218.jar / org.eclipse.emf.ecore_2.7.0.v20110527-1609.jar
But I still get the same exeption.
Any idea which other jars might conflict? Attached a list of all jars in my web-inf/lib.
Philipp
JasonW
Philipp
I do not see the attachment. Any chance you could make a temp web app with just the birt jars. Just to test if the app will start? If you have some way of getting me your web app I could try to debug it.
Jason
donino
Hi Jason, <br />
<br />
I ran into the same issue with tomcat6. My portlet application works perfectly with 2.6.2, im trying to migrate 3.7. <br />
I followed those steps:<br />
<br />
- copied all jar from reportEngine/lib to WEB-INF/lib<br />
- Removed any others jar <br />
- Removed WEB-INF/platform<br />
- built a very simple portlet example, using this code:<br />
<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public static void initBirtEngine(PortletContext pc, String logDirectory, String logLevel) throws Exception {
//birtReportEngine singleton is not initialized
PortletExample37.logger.log( Level.INFO, "birtEngine was not initialized, starting processing...");
EngineConfig config = new EngineConfig();
Level level = Level.FINEST;
config.setLogConfig(logDirectory, level);
IPlatformContext context = new PlatformPortletContext( pc );
config.setPlatformContext( context );
config.setResourcePath("/PortletExample37/resources/report");
try {
PortletExample37.logger.log( Level.INFO, "Trying to start birt Platform...");
Platform.startup( config );
PortletExample37.logger.log( Level.INFO, "Birt Platform has been started");
try {
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
birtReportEngine = factory.createReportEngine( config );
PortletExample37.logger.log( Level.INFO, "Birt engine has been created");
}catch(Exception e){
throw new Exception("Problem during Birt Engine creation:"+e.getMessage());
}
PortletExample37.logger.log( Level.INFO, "birtEngine singleton has been successfully initialized");
}
catch ( BirtException e )
{
PortletExample37.logger.log( Level.SEVERE, "Problem during Platform startup {0}", new Object[]{e.getErrorCode(), e.getMessage()});
PortletExample37.logger.log( Level.SEVERE,getStackTrace(e));
throw new Exception("Problem during Platform startup:"+e.getMessage());
}
}//
</pre>
<br />
Here is the log result:<br />
<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
INFO: Trying to start birt Platform...
29 juil. 2011 19:14:37 example37.birt.PlatformPortletContext getPlatform
INFO: Requesting a new Platform portlet context
29 juil. 2011 19:14:37 example37.birt.PlatformPortletContext deploy
INFO: Platform path: C:\Users\birt\GateIn-3.1.0-FINAL-tomcat\GateIn-3.1.0-GA\webapps\PortletExample37\WEB-INF\platform
29 juil. 2011 19:14:37 example37.birt.PlatformPortletContext getPlatform
INFO: Platform portlet context seemed to be already created with path:C:\Users\birt\GateIn-3.1.0-FINAL-tomcat\GateIn-3.1.0-GA\webapps\PortletExample37\WEB-INF\platform
29 juil. 2011 19:14:41 example37.birt.BirtEngine initBirtEngine
GRAVE: Problem during Platform startup error.CannotStartupOSGIPlatform error.CannotStartupOSGIPlatform {2}
29 juil. 2011 19:14:41 example37.birt.BirtEngine initBirtEngine
GRAVE: org.eclipse.birt.core.exception.BirtException: error.CannotStartupOSGIPlatform
</pre>
<br />
I wonder why "PlatformPortletContext.getPlatform" is called a second time.<br />
<br />
and the stack trace:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
Caused by: org.eclipse.birt.core.framework.FrameworkException
at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:90)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:75)
... 51 more
Caused by: java.security.PrivilegedActionException: org.eclipse.birt.core.framework.FrameworkException: Framework C:\Users\birt\GateIn-3.1.0-FINAL-tomcat\GateIn-3.1.0-GA\webapps\PortletExample37\WEB-INF\platform doesnt exist or is not a directory
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:75)
... 52 more
Caused by: org.eclipse.birt.core.framework.FrameworkException: Framework C:\Users\birt\GateIn-3.1.0-FINAL-tomcat\GateIn-3.1.0-GA\webapps\PortletExample37\WEB-INF\platform doesnt exist or is not a directory
at org.eclipse.birt.core.framework.osgi.OSGILauncher.doStartup(OSGILauncher.java:115)
at org.eclipse.birt.core.framework.osgi.OSGILauncher.access$0(OSGILauncher.java:94)
at org.eclipse.birt.core.framework.osgi.OSGILauncher$1.run(OSGILauncher.java:79)
... 54 more
</pre>
<br />
Because of this stack message i tried to create an empty platform directory under WEB-INF but it doesnt work either:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
Caused by: org.eclipse.birt.core.framework.FrameworkException
at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:90)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:75)
... 51 more
Caused by: java.security.PrivilegedActionException: org.eclipse.birt.core.framework.FrameworkException: Could not find the Framework - org.eclipse.osgi in path C:\Users\birt\GateIn-3.1.0-FINAL-tomcat\GateIn-3.1.0-GA\webapps\PortletExample37\WEB-INF\platform\plugins
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:75)
... 52 more
Caused by: org.eclipse.birt.core.framework.FrameworkException: Could not find the Framework - org.eclipse.osgi in path C:\Users\birt\GateIn-3.1.0-FINAL-tomcat\GateIn-3.1.0-GA\webapps\PortletExample37\WEB-INF\platform\plugins
at org.eclipse.birt.core.framework.osgi.OSGILauncher.doStartup(OSGILauncher.java:123)
at org.eclipse.birt.core.framework.osgi.OSGILauncher.access$0(OSGILauncher.java:94)
at org.eclipse.birt.core.framework.osgi.OSGILauncher$1.run(OSGILauncher.java:79)
... 54 more
</pre>
<br />
May be the problem is due to PlatformPortletContext Class, that i picked up in one of your post somewhere on the web? i suppose it may be modified with 3.7 api? Any will be much appreciated! <br />
<br />
Here is PlatformPortletContext code:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public class PlatformPortletContext implements IPlatformContext
{
static protected Logger log = Logger
.getLogger( PlatformPortletContext.class.getName( ) );
private static final String RESOURCE_BASE = "/WEB-INF/platform/"; //$NON-NLS-1$
private PortletContext context = null; // the ServletContext.
private String platform;
protected PlatformConfig platformConfig;
public PlatformPortletContext( PortletContext context )
{
this.context = context;
}
public String getPlatform( )
{
if ( platform == null )
{
PortletExample37.logger.log( Level.INFO, "Requesting a new Platform portlet context");
synchronized ( this )
{
if ( platform == null )
{
deploy( );
}
}
}
else {PortletExample37.logger.log( Level.INFO, "Platform portlet context seemed to be already created with path:{0}", new Object[]{platform});
}
return platform;
}
/**
* deploy the platform resources to file based platform.
*
*/
private void deploy( )
{
assert platform == null;
platform = context.getRealPath( RESOURCE_BASE );
if ( platform == null )
{
File contextTemp = (File) context
.getAttribute( "javax.servlet.context.tempdir" ); //$NON-NLS-1$
File platformFolder = new File( contextTemp, "platform" );
//Weblogic try to remove the platform but it failes,
//so try to copy the platform each time.
//if ( !platformFolder.exists( ) )
{
platformFolder.mkdir( );
PortletExample37.logger.log( Level.INFO, "Platform folder created in javax.servlet.context.tempdir");
copyResources( RESOURCE_BASE, platformFolder.getAbsolutePath( ) );
PortletExample37.logger.log( Level.INFO, "All resources have been transfered to the new Platform folder");
}
platform = platformFolder.getAbsolutePath( );
}
PortletExample37.logger.log( Level.INFO, "Platform path: {0}", platform);
}//end deploy
// etc... (not used with tomcat)
}
</pre>
JasonW
You should not need a platform context. There is no longer an osgi to deploy so remove that class and this code:
IPlatformContext context = new PlatformPortletContext( pc );
config.setPlatformContext( context );
Jason
donino
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="80810" data-time="1311963415" data-date="29 July 2011 - 11:16 AM"><p>
You should not need a platform context. There is no longer an osgi to deploy so remove that class and this code:<br />
IPlatformContext context = new PlatformPortletContext( pc ); <br />
config.setPlatformContext( context );<br />
<br />
Jason<br /></p></blockquote>
<br />
It works!!! fantastic i'm so happy!! thank you very much Jason
JasonW
Glad you got it working. It would be great if you could post a dev share item with some sample code for others who need to do this.
Jason
rpfister
Back from my holiday I gave a new try to my problem. I removed the platform context from my code it worked! This is the code I just removed:
config.setEngineHome("");
IPlatformContext context = new PlatformServletContext(sc);
config.setPlatformContext(context);
Really great. Many thanks to Jason and donino for their input!
Many regards
Rolf
spoocs
Hi,
following the instructions on upgrading to birt runtime v3.7 (removing platform-folder, moving libs to web-inf/lib now) I get the "CannotStartupOSGIPlatform"-Exception alread on starting up the Tomcat6 (from within Eclipse).
Any hints what could be wrong here? Does anybody has the same issue?
tanks,
josh
JasonW
Josh,
Does it startup ok outside of Eclipse?
Jason
spoocs
Hi Jason,<br />
<br />
yes and no. Within eclipse (with Tomcat configured as workspace metadata location) it is failing on startup with the given error. Clicking a class in the stacktrace (e.g. at org.eclipse.birt.core.framework.Platform.startup(Platform.java:92)) leads to something like 'Invalid line number - 320 is not a valid line naumber..', so it looks pretty much like some library-conflicts. But I don't see where and why.<br />
<br />
Copy it to fresh clean Tomcat7 (with no eclipse connection) it is starting up successfully, but the the OSGi-error occurs on reguesting for the report then.<br />
<br />
So, I keep on searching..
<br />
<br />
thx,<br />
josh<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="83125" data-time="1316634074" data-date="21 September 2011 - 12:41 PM"><p>
Josh,<br />
<br />
Does it startup ok outside of Eclipse?<br />
<br />
Jason<br /></p></blockquote>