Deploying BIRT Report Engine API with Apache Struts

August 15th, 2006 by Samuel Santos Leave a reply »

After reading the great article Deploying BIRT from Jason Weathersby I decide to create a little example on how to use BIRT RE API with Apache Struts framework.

To do so I’ve followed Jason steps:

  1. Create a WebReport/WEB-INF/lib directory underneath the Tomcat webapps directory.
  2. Copy all the jars in the birt-runtime-2_5_2/ReportEngine/lib directory from the Report Engine download into your WebReport/WEB-INF/lib directory.
  3. Next, create a directory named platform in your WEB-INF folder.
  4. Copy the birt-runtime-2_5_2/Report Engine/plugins and birt-runtime-2_5_2/ReportEngine/configuration directories to the platform directory you just created. In this example the context is WebReport, so the folder structure is /webapps/WebReport/platform/plugins and webapps/WebReport/platform/configuration.
  5. Additionally, create directories below WebReport for image location and report location.

And used the same directory structure:

WebReport directory structure

The example allows you to generate reports in HTML, PDF, and XLS formats. For the last one I’ve used Tribix XLS Emitter 2.5.2.

To install Tribix XLS emitter just copy both org.uguess.birt.report.engine.common_2.5.2.201107181644.jar and org.uguess.birt.report.engine.emitter.xls_2.5.2.201107181644.jar files into your /webapps/WebReport/platform/plugins folder.

The following files are mean to replace the WebReportServlet class from Jason example.
Jason’s source code has been updated so you can easily embed the report’s HTML in your JSP pages and correctly render your images and charts in your HTML.

Go to the Resources section to get the instructions on how to get this example source code.

BirtInitializationPlugin.java

Struts Plugin to BIRT Report Engine initialization and shutdown.

/**
 * BIRT Report Engine initialization and shutdown Plugin.
 * 
 * @author : samaxes
 * @version : $Revision$
 */
public class BirtInitializationPlugin implements PlugIn {

    /**
     * Initialization of the servlet. <br />
     * 
     * @param servlet ActionServlet
     * @param conf ModuleConfig
     * @throws ServletException if an error occure
     */
    public void init(ActionServlet servlet, ModuleConfig conf) throws ServletException {
        BirtEngine.initBirtConfig();
    }

    /**
     * Destruction of the servlet.
     */
    public void destroy() {
        BirtEngine.destroyBirtEngine();
    }

}

WebReportAction.java

Actions related to the reports generation.

/**
 * Actions related to the reports generation.
 * 
 * @author : samaxes
 * @version : $Revision$
 */
public class WebReportAction extends MappingDispatchAction {

    private IReportEngine birtReportEngine = null;

    protected static Logger logger = Logger.getLogger("org.eclipse.birt");

    /**
     * The html report action. <br />
     * Gets the report's html output stream.
     * 
     * @param actionMapping ActionMapping
     * @param actionForm ActionForm
     * @param request HttpServletRequest
     * @param response HttpServletResponse
     * @return ActionForward
     */
    public ActionForward htmlReportAction(ActionMapping actionMapping, ActionForm actionForm,
            HttpServletRequest request, HttpServletResponse response) {

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        try {
            out = renderReportPage(request);
        } catch (ServletException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        }

        request.setAttribute("reportHTML", out);

        return actionMapping.findForward(Constants.FORWARD_SUCCESS);
    }

    /**
     * Generates the html report.
     * 
     * @param request HttpServletRequest
     * @return ByteArrayOutputStreamwith the report generated
     * @throws ServletException
     */
    private ByteArrayOutputStream renderReportPage(HttpServletRequest request) throws ServletException {

        // get report name and launch the engine
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        String reportName = request.getParameter("ReportName");
        ServletContext sc = request.getSession().getServletContext();
        this.birtReportEngine = BirtEngine.getBirtEngine(sc);

        IReportRunnable design;
        try {
            // Open report design
            design = birtReportEngine.openReportDesign(sc.getRealPath("/reports") + "/" + reportName);
            // create task to run and render report
            IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(design);

            // set output options
            IHTMLRenderOption options = new HTMLRenderOption();
            options.setOutputFormat(IHTMLRenderOption.OUTPUT_FORMAT_HTML);
            options.setEmbeddable(true);
            options.setOutputStream(out);

            // set the image handler to a HTMLServerImageHandler if you plan on using the base image url.
            options.setImageHandler(new HTMLServerImageHandler());
            options.setBaseImageURL(request.getContextPath() + "/images");
            options.setImageDirectory(sc.getRealPath("/images"));

            // run report
            task.setRenderOption(options);
            task.run();
            task.close();
        } catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            throw new ServletException(e);
        }

        return out;
    }

    /**
     * The pdf report action. <br />
     * Generates the pdf report.
     * 
     * @param actionMapping ActionMapping
     * @param actionForm ActionForm
     * @param request HttpServletRequest
     * @param response HttpServletResponse
     * @throws ServletException
     */
    public void pdfReportAction(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) throws ServletException {

        // get report name and launch the engine
        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition", "inline; filename=WebReport.pdf"); // inline, attachment
        String reportName = request.getParameter("ReportName");
        ServletContext sc = request.getSession().getServletContext();
        this.birtReportEngine = BirtEngine.getBirtEngine(sc);

        IReportRunnable design;
        try {
            // Open report design
            design = birtReportEngine.openReportDesign(sc.getRealPath("/reports") + "/" + reportName);
            // create task to run and render report
            IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(design);

            // set output options
            IPDFRenderOption options = new PDFRenderOption();
            options.setOutputFormat(IPDFRenderOption.OUTPUT_FORMAT_PDF);
            options.setOutputStream(response.getOutputStream());

            // run report
            task.setRenderOption(options);
            task.run();
            task.close();
        } catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            throw new ServletException(e);
        }
    }

    /**
     * The excel report action. <br />
     * Generates the excel report.
     * 
     * @param actionMapping ActionMapping
     * @param actionForm ActionForm
     * @param request HttpServletRequest
     * @param response HttpServletResponse
     * @throws ServletException
     */
    public void xlsReportAction(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) throws ServletException {

        // get report name and launch the engine
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "inline; filename=WebReport.xls"); // inline, attachment
        String reportName = request.getParameter("ReportName");
        ServletContext sc = request.getSession().getServletContext();
        this.birtReportEngine = BirtEngine.getBirtEngine(sc);

        IReportRunnable design;
        try {
            // Open report design
            design = birtReportEngine.openReportDesign(sc.getRealPath("/reports") + "/" + reportName);
            // create task to run and render report
            IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(design);

            // set output options
            IExcelRenderOption options = new EXCELRenderOption();
            options.setOutputFormat(Constants.XLS_FORMAT);
            options.setOutputStream(response.getOutputStream());

            // run report
            task.setRenderOption(options);
            task.run();
            task.close();
        } catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            throw new ServletException(e);
        }
    }

}

All you need to get this sample running is to copy the WAR file to your server deploy dir and configure the BIRT Report Engine logging in BirtConfig.properties file:

logDirectory=C:/work/logs/birt
logLevel=CONFIG

If you are building the application from the source code you must also configure the application server deployment directory.
In order to do so, rename the file build.properties-sample to build.properties and edit the following line:

deploy.dir=C:/work/jboss/server/default/deploy

Designing the report is out of the scope of this article, you can found lots of good tutorials on the Web and on BIRT Website.

Resources

Don't be shellfish...Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInPin on PinterestBuffer this pageEmail this to someone
Advertisement

29 comments

  1. Great example. It would be great if you could add this to the Eclipse Wiki.
    Take a look at this site:
    http://wiki.eclipse.org/index.php/Servlet_Example

    If you have a Bugzilla account you can post it in the comments section of this example.

    Thanks

    Jason

  2. Yassine says:

    Hi,

    thank you for this valuable example, thank you Jason too.

    Actually, I’m developing a web application that allow users to generate reports based on some parameters. So, I do need to access a database on the fly (run time). But in this example, and in Jason’s one I’m not able to find something like that, because your rpdesign file is already generated (maybe using the report designer in eclipse.

    Also, I’m using Struts as an MVC framework, and don’t want to violate my design by using the BIRT viewer servlet, So what about the AJAX facilities in this case? I do want to take advantage of it

  3. This article is just about the deployment of the BIRT Report Engine and have it running.

    But you can found more info about how to use the Report Engine API to satisfy your needs (passing parameters in runtime and integrating with your web application without using BIRT Viewer) in this page:

    http://www.eclipse.org/birt/phoenix/deploy/

    Hope this help,
    Samuel

  4. Yassine says:

    Thanks A lot Sam for your reply. Actually,I eventually adopted a combination of Displaytag and the jfreechart based cewolf taglib (because of deadlines ;). Nonetheless Birt Report engine API seems to be more powerful so I’ll keep investigating this solution and glance through the page you gave me.

    Thanks,
    Yassine.

  5. Satya says:

    Nice article. However i observed an issue – the generated output i.e., the html will have “file://c:……” reference to the images instead of URL (even though we specify the baseImageUrl).

    I have tested this with one of my report which contain charts. I found that charts , in the form of images, are aptly created in the specified images directory, but fail to display on the browser since the fully qualified path contains file: protocol instead of http:

    Am i missing anything?

    Thanks
    Satya

  6. Satya says:

    Oh, i have added the following lines and now its working:

    ————————
    htmlemitterconfig.setActionHandler(new HTMLActionHandler());
    htmlemitterconfig.setImageHandler(new HTMLServerImageHandler());
    config.getEmitterConfigs().put(“html”, htmlemitterconfig);
    —————————-

    -satya

  7. Thanks a lot Satya for reporting this.

    I’ll update the code as soon as I can.

    Samuel

  8. rich says:

    good example!! it really helps a lot for me.

  9. The source code has been updated to fix the bug reported by Satya.

    Samuel

  10. The BIRT Runtime has been updated to Release Build 2.1.2

  11. Soumya says:

    Hi,

    Can anyone tell me, i have created a report which uses a library.
    Now i try running this report on some other machine which has web viewer installed. Where do i copy the library contents so that the report picks them up properly.
    I am using jboss as my server.
    Please help!

  12. John says:

    you said ‘The source code has been updated so you can easily embed the report’s HTML in your JSP pages and correctly render your images and charts in your HTML.’
    Can you give further explanations on how to do that ?

  13. Looking at the WebReportAction you can easily put the report in the request request.setAttribute("reportHTML", out); and print it in the jsp like ${reportHTML} in viewReport.jsp file.

  14. gemidise says:

    Hi Samuel,
    I came across these error while I’m deploying birt to struts 1.3.8 with tiles and sslext. Pls advice whether Birt came deployed to which struts version and what went wrong with it ? Thanks in advance.

    18:10:37,718 INFO [STDOUT] In htmlReportAction …
    18:10:37,718 INFO [STDOUT] In renderReportPage …
    18:10:37,718 INFO [STDOUT] reportName
    18:10:37,718 INFO [STDOUT] getContextPath
    18:10:37,718 INFO [STDOUT] In com.ufu.util.BirtEngine …
    18:10:37,734 INFO [STDOUT] logLevel
    18:10:37,734 INFO [STDOUT] level
    18:10:37,734 INFO [STDOUT] logDirectory
    18:10:37,734 INFO [STDOUT] getBIRTHome
    18:10:37,734 INFO [STDOUT] getLogDirectory
    18:10:37,734 INFO [STDOUT] getMaxRowsPerQuery
    18:10:37,734 INFO [STDOUT] getResourcePath
    18:10:37,734 INFO [STDOUT] LOG_LEVEL
    18:10:37,734 INFO [STDOUT] LOG_DESTINATION
    18:10:37,734 INFO [STDOUT] OSGI_ARGUMENTS
    18:10:37,734 INFO [STDOUT] OSGI_CONFIGURATION
    18:10:38,734 ERROR [STDERR] java.lang.reflect.InvocationTargetException
    18:10:38,734 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    18:10:38,734 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    18:10:38,734 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    18:10:38,734 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
    18:10:38,734 ERROR [STDERR] at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:169)
    18:10:38,734 ERROR [STDERR] at org.eclipse.birt.core.framework.Platform.startup(Platform.java:77)
    18:10:38,734 ERROR [STDERR] at com.ufu.util.BirtEngine.getBirtEngine(BirtEngine.java:76)
    18:10:38,734 ERROR [STDERR] at com.ufu.struts.reports.action.WebReportAction.renderReportPage(WebReportAction.java:53)
    18:10:38,734 ERROR [STDERR] at com.ufu.struts.reports.action.WebReportAction.htmlReportAction(WebReportAction.java:34)
    18:10:38,734 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    18:10:38,734 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    18:10:38,734 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    18:10:38,734 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
    18:10:38,734 ERROR [STDERR] at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
    18:10:38,734 ERROR [STDERR] at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
    18:10:38,734 ERROR [STDERR] at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:166)
    18:10:38,734 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
    18:10:38,734 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
    18:10:38,734 ERROR [STDERR] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    18:10:38,734 ERROR [STDERR] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    18:10:38,734 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
    18:10:38,734 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    18:10:38,734 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    18:10:38,734 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
    18:10:38,734 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    18:10:38,734 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    18:10:38,734 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    18:10:38,734 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    18:10:38,750 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    18:10:38,750 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    18:10:38,750 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    18:10:38,750 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
    18:10:38,750 ERROR [STDERR] Caused by: java.lang.LinkageError: org/jboss/net/protocol/file/Handler
    18:10:38,750 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
    18:10:38,750 ERROR [STDERR] at java.lang.Class.forName(Class.java:164)
    18:10:38,750 ERROR [STDERR] at org.eclipse.osgi.framework.util.SecureAction.forName(SecureAction.java:309)
    18:10:38,750 ERROR [STDERR] at org.eclipse.osgi.framework.internal.protocol.StreamHandlerFactory.getBuiltIn(StreamHandlerFactory.java:66)
    18:10:38,750 ERROR [STDERR] at org.eclipse.osgi.framework.internal.protocol.StreamHandlerFactory.createURLStreamHandler(StreamHandlerFactory.java:86)
    18:10:38,750 ERROR [STDERR] at java.net.URL.getURLStreamHandler(URL.java:1104)
    18:10:38,750 ERROR [STDERR] at java.net.URL.(URL.java:393)
    18:10:38,750 ERROR [STDERR] at java.net.URL.(URL.java:283)
    18:10:38,750 ERROR [STDERR] at java.net.URL.(URL.java:306)
    18:10:38,750 ERROR [STDERR] at java.io.File.toURL(File.java:594)
    18:10:38,750 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.getURL(WebappClassLoader.java:2298)
    18:10:38,750 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:1969)
    18:10:38,750 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1752)
    18:10:38,750 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:869)
    18:10:38,750 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1322)
    18:10:38,750 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    18:10:38,750 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    18:10:38,750 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    18:10:38,750 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
    18:10:38,750 ERROR [STDERR] at java.lang.Class.forName(Class.java:164)
    18:10:38,750 ERROR [STDERR] at org.eclipse.osgi.framework.util.SecureAction.forName(SecureAction.java:309)
    18:10:38,750 ERROR [STDERR] at org.eclipse.osgi.framework.internal.protocol.StreamHandlerFactory.getBuiltIn(StreamHandlerFactory.java:66)
    18:10:38,750 ERROR [STDERR] at org.eclipse.osgi.framework.internal.protocol.StreamHandlerFactory.createURLStreamHandler(StreamHandlerFactory.java:86)
    18:10:38,750 ERROR [STDERR] at java.net.URL.getURLStreamHandler(URL.java:1104)
    18:10:38,750 ERROR [STDERR] at java.net.URL.(URL.java:572)
    18:10:38,750 ERROR [STDERR] at java.net.URL.(URL.java:464)
    18:10:38,750 ERROR [STDERR] at java.net.URL.(URL.java:413)
    18:10:38,750 ERROR [STDERR] at org.eclipse.core.runtime.adaptor.EclipseStarter.getSysPathFromURL(EclipseStarter.java:979)
    18:10:38,750 ERROR [STDERR] at org.eclipse.core.runtime.adaptor.EclipseStarter.getSysPath(EclipseStarter.java:960)
    18:10:38,750 ERROR [STDERR] at org.eclipse.core.runtime.adaptor.EclipseStarter.getInitialBundles(EclipseStarter.java:668)
    18:10:38,750 ERROR [STDERR] at org.eclipse.core.runtime.adaptor.EclipseStarter.loadBasicBundles(EclipseStarter.java:637)
    18:10:38,750 ERROR [STDERR] at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:305)
    18:10:38,750 ERROR [STDERR] … 41 more
    18:10:38,750 INFO [STDOUT] 18:10:38,750 WARN [PropertyMessageResources] Resource org/apache/struts/actions/LocalStrings_en_US.properties Not Found.
    18:10:38,765 INFO [STDOUT] 18:10:38,765 WARN [PropertyMessageResources] Resource org/apache/struts/actions/LocalStrings_en.properties Not Found.
    18:10:38,765 ERROR [CoyoteAdapter] An exception or error occurred in the container during the request processing

  15. This example was deployed with Struts 1.2.9, I’ve never used Struts 1.3.x or Struts 2.x. Stripes Framework rules :)

  16. Brage says:

    Hi, Thanks a lot for your example!
    I met a problem that when I deployed your example to my system,
    I found the var factory in the BirtEngine.java is null.
    How can I fix it?
    May you do me a favor?
    Thanks very much!

  17. Sorry, but I can’t reproduce the error.
    I deployed the war into jboss and all seems to work normally.

  18. Arijit Mallick says:

    Excellent Example. Thanks a lot!!!

  19. Natalia says:

    Hello,
    Greate example. I am trying to integrate it in my J2ee web application, and i would like to know if all the libraries and files in
    WEB-INF\platform\plugins necesary in run time?

    Thanks in advanced!

  20. Arijit Mallick says:

    Thats really important to know if all the files are required under platform. Actually if we can cut down the number of jars the application becomes light. It is also now know if we need all the jars (18 jars) under WEB-INF\lib. Compile time dependency need only 3 jars in the lib.

    Thanks for the help

  21. Hi,
    I didn’t try to remove the files.
    I’ve just followed the documentation which tells to copy all the files.
    I assume that since they come bundled with the Report Engine it’s probably because they are necessary.

  22. Jigar Shah says:

    By any chance with struts2 ?

  23. Sorry, I do not work with Struts2.

  24. sandrar says:

    Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

  25. eqa says:

    Can u pls help me to fix the problem?
    I am getting following error
    java.lang.NullPointerException
    com.samaxes.webreport.birt.BirtEngine.getBirtEngine(BirtEngine.java:104)

    • This example was using BIRT 2.1.2 which is very old and don’t work anymore with current Java releases.

      I’ve update the example to use BIRT 2.5.2 in order for you to be able to try it.

  26. Ankith says:

    Hi,
    i got this error ..any one solve this error please..

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: java.lang.NullPointerException
    com.samaxes.webreport.action.WebReportAction.xlsReportAction(WebReportAction.java:195)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
    org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
    org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    root cause

    java.lang.NullPointerException
    org.eclipse.birt.report.model.api.DesignEngine.newSessionHandle(DesignEngine.java:108)
    org.eclipse.birt.report.engine.parser.ReportParser.getDesignHandle(ReportParser.java:143)
    org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.getReportDesignHandle(ReportEngineHelper.java:255)
    org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:274)
    org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:196)
    org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReportDesign(ReportEngineHelper.java:130)
    org.eclipse.birt.report.engine.api.impl.ReportEngine.openReportDesign(ReportEngine.java:295)
    com.samaxes.webreport.action.WebReportAction.xlsReportAction(WebReportAction.java:182)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
    org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
    org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

    • Hi Ankith,

      I’m not able to reproduce your error.
      I just downloaded a fresh copy of Tomcat 6.0.29, downloaded the sample application webreport-struts-1.1.0.war from http://code.google.com/p/struts-birt-webreport/downloads/list, and deployed it into Tomcat.
      I got this output:

      INFO: Server startup in 6084 ms
      Out 17, 2012 11:17:13 PM org.eclipse.birt.report.data.adapter.impl.ModelAdapter adaptDataSet
      WARNING: handle type: org.eclipse.birt.report.model.api.OdaDataSetHandle
      Out 17, 2012 11:17:13 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
      INFO: Found JDBC driverinfo extension: driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null
      Out 17, 2012 11:17:13 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions
      INFO: Found JDBC driverinfo extension: driverClass=org.eclipse.birt.report.data.oda.sampledb.Driver, connectionFactory=org.eclipse.birt.report.data.oda.sampledb.SampleDBJDBCConnectionFactory
      Out 17, 2012 11:17:13 PM org.eclipse.birt.report.data.oda.sampledb.SampledbPlugin start
      INFO: Sampledb plugin starts up. Current startCount=0
      Out 17, 2012 11:17:13 PM org.eclipse.birt.report.data.oda.sampledb.SampledbPlugin init
      INFO: Creating Sampledb database at location .../apache-tomcat-6.0.29/temp/BIRTSampleDB_1350512233716_604b0e7b
      

Leave a Reply